一个解决方案中的第二个 WPF 项目出现 log4Net 错误
我对以下错误完全感到困惑。
我的应用程序运行得很好,并使用 log4net 进行日志记录。
我现在将实施我自己的更新系统。我希望它成为我解决方案的一部分。
我已向我的解决方案添加了一个新的 WPF 应用程序,当我尝试编辑该项目中的主窗口或任何其他窗口时,我收到以下错误消息:
/Microsoft.VisualStudio.Xaml;Component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.Constants.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'.
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies.
The system cannot find the file specified. Error at object 'ResourceDictionary_2' in markup file 'Microsoft.VisualStudio.Xaml;component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.xaml.
有人有任何建议吗?
编辑:当我在新项目中引用 log4net.dll 时,设计器就工作了,但为什么我需要在每个项目中引用它?
I am totally confused with the following error.
I have my application which works perfectly fine and uses log4net for logging.
I will now be implementing my own updater system. And I want it to be part of my solution.
I have added a new WPF Application to my Solution and when I try to edit the main window or any other window in that project I get the following error message:
/Microsoft.VisualStudio.Xaml;Component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.Constants.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'.
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies.
The system cannot find the file specified. Error at object 'ResourceDictionary_2' in markup file 'Microsoft.VisualStudio.Xaml;component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.xaml.
Anyone have any suggestions?
EDIT: The designer works when i reference log4net.dll in the new project, but why do i need to reference it in every project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不太确定为什么会发生这种情况,但是将 WPF 项目的 TargetFramework 从“.NET Framework 4 Client Profile”(这是 VS2010 WPF 项目模板中的默认值)更改为“.NET Framework 4”修复了相同的问题我。我猜发生这种情况是因为 Log4Net dll 的 dll 签名(强命名)。
I am not exactly sure why this happens, but changing the TargetFramework of the WPF project to ".NET Framework 4" from ".NET Framework 4 Client Profile"(which is the default in the VS2010 WPF project template) fixed the same problem for me. I guess this happens because the dll signing(strong naming) of Log4Net dll.
如果您没有在新项目中使用 log4net 库,只需编辑 ResourceDictionary 并删除对 log4net 库的引用即可。听起来您正在为两个 WPF 项目使用同一个库,并且该库对 log4net 有一些参考。这就是交叉似乎来自的地方。
If you aren't using the log4net library in the new project, simply edit the ResourceDictionary and remove the reference to the log4net library. It sounds like you are using one library for both WPF projects and the library has some reference to log4net. That is where the crossover seems to be coming from.