我在项目中加载任何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项目,但是在一个全新的解决方案中也没有。我发现我不是唯一有这个问题的人,并且想知道你是否对我有任何想法。
Here is a post of someone with the same error, from Google Cache.
答案 0 :(得分:0)
堆栈跟踪表明您没有对项目中指定的log4net程序集的引用。解决方案是添加对它的引用,尽管除非你得到一个针对Silverlight agCLR运行时编译的log4net程序集,否则你将无法做到。
如果您不想在Silverlight应用程序中使用log4net,则替代方法是删除尝试使用它的代码部分。再次从堆栈跟踪看起来,您正在设置某种初始化log4net的资源。尝试打开您的Windox.xaml并查看资源部分。如果你看到任何log4net的迹象,那么删除它们,看看它是否有帮助。
答案 1 :(得分:0)
我也遇到了这个错误。我已经完成了应用程序,并确保我引用了正确的版本。 silverlight应用程序中没有使用log4net,仅在包含应用程序使用的wcf服务的Web项目中。看起来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; component / MS / Internal / Designer / PropertyEditing / Resources / StylesCore.xaml'中对象'ResourceDictionary_2'出错。
答案 2 :(得分:0)
我不知道问题的根源是什么。如果有人知道我会有兴趣了解!
我有一个解决方法虽然为我解决了它:
最后再使用log4net和引用添加项目。
的Henrik