我在尝试使用企业库验证应用程序块时遇到以下异常:
创建用于验证的配置节处理程序时出错:无法加载文件或程序集"Microsoft.Practices.EnterpriseLibrary.Validation,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)(C:\ Documents and Settings\My Documents\Visual Studio 2008\Projects\Testers\TestProject\web.config第12行)
我知道异常试图告诉我什么,但我无法弄清楚如何解决它.我只安装了一个版本的企业库,这就是它(4.1.0.0),所以我看不出它是如何找到错误的版本,所以我想它是一个依赖问题.我已经从企业库4.1中包含了"Common","Validation"和"ObjectBuilder2"DLL作为项目中的参考,所以我不确定我还缺少什么.文档肯定似乎表明这就是我所需要的.
有没有办法找出依赖问题是什么?
如果有帮助,我尝试使用企业库配置工具创建验证应用程序块规则集,以验证实体框架实体中的数据.我在Visual Studio 2008中使用ASP.NET MVC.
感谢您提供的任何帮助/指导,
克里斯
Microsoft Enterprise Library有一些有争议的反馈.一些开发人员喜欢它,有人说它是过度设计的.有什么替代品吗?免费和商业.
如何通过EntLib 5.0将表值参数传递给SQL Server 2008?
我收到有关我们的实时环境中罕见且间歇性错误的报告.我尝试重现它并没有成功,错误本身就是一个小谜.除此之外,它似乎涉及企业库跟踪(我们使用的是5.0版本) - 总而言之,有点痛苦.这是在Windows Sever 2008上发生的,应用程序在.Net Framework 4.0(WPF)上.
错误消息和堆栈跟踪如下:
ArgumentNullException: Value cannot be null. Parameter name: category
<StackTrace>
Server stack trace:
at Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry.BuildCategoriesCollection(String category)
at Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.WriteTraceMessage(String message, String entryTitle, TraceEventType eventType)
at Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.WriteTraceEndMessage(String entryTitle)
at Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.Dispose()
at TestApplication.ViewModelTest.<UpdateUsers>d__1a.MoveNext()
Exception rethrown at [0]:
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.<SetException>b__1(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
</StackTrace> …Run Code Online (Sandbox Code Playgroud) 如果我改变了......
EventSource(Name="BasicLogger")
public class BasicLogger : EventSource { ... }
Run Code Online (Sandbox Code Playgroud)
对...
EventSource(Name="HardymanDatabaseLog")
public class BasicLogger : EventSource { ... }
Run Code Online (Sandbox Code Playgroud)
...我仍然收到日志消息,但它们已损坏.
消息没有到达,或者它们是由当前项目中甚至不存在的缺失/删除/删除方法格式化的!
由于某些未知原因,特定字符串'HardymanDatabaseLog'存在问题
我认为这可能归结为一个在某个地方表现出来的腐败仪器清单.
请继续阅读以了解更多信息 ...!(谢谢:o))
我有一个简单的控制台应用程序,EnterpriseLibrary.SemanticLogging通过nuget包引用.
使用这里的示例代码,我添加了一个BasicLogger类.
当我运行我的简单应用程序时......
using System.ComponentModel;
using System.Diagnostics.Tracing;
namespace Etw
{
class Program
{
static void Main(string[] args)
{
BasicLogger.Log.Error("Hello1");
BasicLogger.Log.Critical("Hello2");
}
}
[EventSource(Name = "BasicLogger")]
public class BasicLogger : EventSource
{
public static readonly BasicLogger Log = new BasicLogger();
[Event(1, Message = "{0}", Level = EventLevel.Critical)] …Run Code Online (Sandbox Code Playgroud) 我有一个JAR文件用于授权.我需要为每个WAR文件使用它.所有WAR文件都打包在EAR文件中.我是否必须在每个WAR中重复这个常见的JAR,或者是否存在公共库的结构?
所以我的例子看起来像这样......
big.ear
- META-INF
- MANIFEST.MF
- application.xml
- appl1.war
- META-INF
- MANIFEST.MF
- WEB-INF
- web.xml
- lib
- unique1.jar
- unique2.jar
- unique3.jar
- common1.jar
- jsps/html/etc
- appl2.war
- META-INF
- MANIFEST.MF
- WEB-INF
- web.xml
- lib
- unique3.jar
- unique4.jar
- common1.jar
- jsps/html/etc
- appl3.war
- META-INF
- MANIFEST.MF
- WEB-INF
- web.xml
- lib
- unique5.jar
- common1.jar
- jsps/html/etc
Run Code Online (Sandbox Code Playgroud)
我的每个WAR应用程序都可以看到common1.jar,但它在EAR中有三次.
我可以在EAR结构中放置common1.jar,以便appl1,appl2和appl3可以看到它而不重复三次?
我正在尝试使用Microsoft企业库中的DatabaseFactory方法.
using Microsoft.Practices.EnterpriseLibrary.Data;
Run Code Online (Sandbox Code Playgroud)
我得到的错误是: The type or namespace 'Practices' does not exist in the namespace Microsoft
我尝试去微软的网站安装企业库,完成安装过程,但仍然无法正常工作.我把它安装到了错误的位置吗?有任何想法吗?
编辑:我遵循了Kev的指示,让一切正常.谢谢你们的帮助.
我正在使用Microsoft企业库将一些日志写入事件日志
它的写入记录很好,但似乎没有在事件日志中设置类别.该类别在日志的消息正文中显示正常(如果我选择设置该类别),但事件查看器不会选择该类别.
我错过了什么?
c#来源
LogEntry log = new LogEntry();
log.Message = "Test";
log.Categories.Add("Event");
Logger.Write(log);
Run Code Online (Sandbox Code Playgroud)
网络配置
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add source="TestLogSource" formatter="Text Formatter" log="TestLog"
machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Formatted EventLog TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}
Message: {message}
Category: {category}
Severity: {severity}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="Events">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
<add switchValue="All" name="General">
<listeners>
<add …Run Code Online (Sandbox Code Playgroud) 我有一个相当简单的内部ASP.Net网站,每周大约加载一次Microsoft.Practices.EnterpriseLibrary.Data dll.这是Exception消息:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.
File name: 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'
at foobar.Intranet.Logic.Data.UserDB.SelectByUserName(String userName)
at foobar.Intranet.Logic.Info.User.ValidateUser(String userName) in F:\Development\foobar\foobar\foobar.Intranet.Logic\Info\User.cs:line 130
at Login.ValidateUser(String username, String password) in e:\foobar\foobar.Intranet\Login.aspx.cs:line 32
=== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///E:/foobar/foobar.Intranet/
LOG: Initial PrivatePath = E:\foobar\foobar.Intranet\bin Calling assembly : foobar.Intranet.Logic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This …Run Code Online (Sandbox Code Playgroud) 对于我们使用Enterprise Library 5的项目,将使用几个块.我倾向于使用Logging应用程序块,因为它内置于此框架中.但我确实看到了很多关于log4net的建议,那么人们选择做什么,如果选择log4net,你为什么选择其他一些?
谢谢.
c# ×6
.net ×3
logging ×2
asp.net ×1
asp.net-mvc ×1
assemblies ×1
enterprise ×1
java ×1
java-ee ×1
log4net ×1
sql ×1