Log4net 奇怪的Silverlight设计器错误

Log4net 奇怪的Silverlight设计器错误,log4net,Log4net,在我的项目中加载任何Xaml时出现以下异常: '/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

在我的项目中加载任何Xaml时出现以下异常:

'/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'.
   at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
   at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
   at System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)
   at System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(String attribValue, Int16 attributeId, Int16 converterTypeId)
   at System.Windows.Markup.BamlRecordReader.ReadPropertyConverterRecord(BamlPropertyWithConverterRecord bamlPropertyRecord)
   at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
   at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
   at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
   at System.Windows.Markup.TreeBuilder.Parse()
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
   at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
   at System.Windows.Application.LoadComponent(Uri resourceLocator)
   at MS.Internal.Designer.PropertyEditing.Resources.PropertyInspectorResources.GetResources()
   at MS.Internal.Designer.PropertyEditing.PropertyInspectorHost.get_Host()
   at MS.Internal.Designer.VSDesigner.VSDesignerClientImpl.get_PropertyWindow()
   at MS.Internal.Designer.VSDesignerClient.get_PropertyWindow()
   at MS.Internal.Designer.DesignerPane.LoadDesignerView()
即使在我的解决方案中生成一个新的SilverLight项目,但在一个全新的解决方案中也不会发生这种情况。我发现我不是唯一一个有这个问题的人,我想知道你是否对我有什么想法


堆栈跟踪表明项目中没有对指定log4net程序集的引用。解决方案是添加一个对它的引用,尽管除非您获得一个针对Silverlight agCLR运行时编译的log4net程序集,否则您将无法使用它


如果您不想在Silverlight应用程序中使用log4net,另一种选择是删除试图使用它的代码部分。从堆栈跟踪来看,似乎您正在设置初始化log4net的某种资源。尝试打开Windox.xaml并查看资源部分。如果您看到log4net的任何迹象,请删除它们并查看是否有帮助。

堆栈跟踪表明您在项目中没有对指定log4net程序集的引用。解决方案是添加一个对它的引用,尽管除非您获得一个针对Silverlight agCLR运行时编译的log4net程序集,否则您将无法使用它


如果您不想在Silverlight应用程序中使用log4net,另一种选择是删除试图使用它的代码部分。从堆栈跟踪来看,似乎您正在设置初始化log4net的某种资源。尝试打开Windox.xaml并查看资源部分。如果您在那里看到任何log4net的迹象,请删除它们并查看是否有帮助。

我也收到了这个错误。我已经检查了应用程序,并确保引用了正确的版本。在silverlight应用程序中不使用log4net,只在包含应用程序使用的wcf服务的web项目中使用log4net。看起来log4net必须被更安全的东西所取代。log4net dll也导致mstest项目停止工作


'/Microsoft.VisualStudio.Xaml;Component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.Constants.xaml值不能分配给对象“System.Windows.ResourceDictionary”的属性“Source”。无法加载文件或程序集“log4net,Version=1.2.10.0,Culture=neutral,PublicKeyToken=1b44e1d426115821”或其依赖项之一。系统找不到指定的文件。标记文件“Microsoft.VisualStudio.Xaml”中的对象“ResourceDictionary_2”处出错;component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.xaml.

我也收到了这个错误。我已经检查了应用程序,并确保引用了正确的版本。在silverlight应用程序中不使用log4net,只在包含应用程序使用的wcf服务的web项目中使用log4net。看起来log4net必须被更安全的东西所取代。log4net dll也导致mstest项目停止工作


'/Microsoft.VisualStudio.Xaml;Component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.Constants.xaml值不能分配给对象“System.Windows.ResourceDictionary”的属性“Source”。无法加载文件或程序集“log4net,Version=1.2.10.0,Culture=neutral,PublicKeyToken=1b44e1d426115821”或其依赖项之一。系统找不到指定的文件。标记文件“Microsoft.VisualStudio.Xaml”中的对象“ResourceDictionary_2”处出错;component/MS/Internal/Designer/PropertyEditing/Resources/StylesCore.xaml.

我不知道问题的原因是什么。如果有人知道的话,我会感兴趣的

不过,我有一个变通办法,可以解决这个问题:

  • 从Silverlight项目中删除对使用log4net的任何对象的引用
  • 使用log4net从解决方案中删除该项目
  • 重新加载XAML页面并保存解决方案
  • 最后使用log4net添加项目并再次添加引用

    亨里克


  • 我不知道问题的起因是什么。如果有人知道的话,我会感兴趣的

    不过,我有一个变通办法,可以解决这个问题:

  • 从Silverlight项目中删除对使用log4net的任何对象的引用
  • 使用log4net从解决方案中删除该项目
  • 重新加载XAML页面并保存解决方案
  • 最后使用log4net添加项目并再次添加引用

    亨里克


  • 我的解决方案使用log4net。由于我的程序集不是针对Silverlight运行时编译的,所以我的项目没有,也不能引用log4net。同样,这是自动生成的“new silverlight project”,它在设计器中抛出此错误…注意:此项目中的所有文件都没有引用log4net。这真的是设计师的崩溃。。。该应用程序在部署时运行和编译良好。这是一个非常复杂的应用程序。如果在记事本中打开罪犯项目文件,是否有任何log4net引用?我不知道log4net如何或为什么会参与一个新的SL项目,我唯一的猜测是安装log4net导致它将自己添加到所有VS.Net模板中。记事本中绝对没有任何引用。。。。如果我在我的解决方案之外工作,设计师就会工作。但事实并非如此,即使是现有的Silverlight项目,以前也在它内部工作过!我很同情,这是令人头痛的事!我使用Expression Blend,已经记不清我重新安装它以使SL应用程序工作或尝试解决设计器加载问题的次数。希望对您的问题有直接经验的人会来。我的解决方案使用log4net。由于我的程序集不是针对Silverlight运行时编译的,所以我的项目没有,也不能引用log4net。同样,这是自动生成的“new silverlight project”,它在设计器中抛出此错误…注意:此项目中的所有文件都没有引用log4net。这真的是设计师的崩溃。。。该应用程序运行并编译f