tags:

views:

681

answers:

3

I get the following exception loading any Xaml in my project:

'/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()

This occurs even when I generate a new SilverLight project inside my solution, but not in a brand new solution. I've found that I am not the only person with this issue, and was wondering if you had any ideas for me.

Here is a post of someone with the same error, from Google Cache.

A: 

The stack trace is indicating you don't have a reference to the specified log4net assembly in your project. The solution would be to add a reference to it, although unless you get a log4net assembly that has been compiled against the Silverlight agCLR runtime you won't be able to.

The alternative if you are not trying to use log4net in your Silverlight app is to remove the sections of code attempting to use it. Again from the stack trace it looks like you are setting up some kind of resource that initialises log4net. Try opening your Windox.xaml and take a look in the reources section. If you see any signs of log4net there remove them and see if it helps.

sipwiz
My solution uses log4net. My project doesn't and I cannot reference log4net given my assembly was not compiled against the Silverlight runtime. Again, this is the auto-generated "new silverlight project" that throws this error in the designer...
Jason Kealey
Jason Kealey
That's a wierd one. If you open up the culprit project file in notepad are there any log4net references hanging around? I don't know how or why log4net would get involved in a new SL project my only wild guess would be installing log4net caused it to add itself to all VS.Net templates.
sipwiz
There are absolutely no reference anywhere in notepad.... and the designer works if I work outside of my solution. But doesn't, even for existing Silverlight projects that did work previously inside it!
Jason Kealey
I sympathise, it's head wrecking stuff! I use Expression Blend and have lost count of the number of times I have re-installed it to get SL apps working or to try and sort out designer loading issues. Hopefully someone with direct experience of your issue will come along.
sipwiz
A: 

I also am getting this error. I have gone through the application and made sure I am referencing the correct version. There is no use of log4net in the silverlight application, only in the web project containing a wcf service that the app uses. It looks like log4net has to be replaced with something safer. The log4net dll is also causing mstest projects to stop working.

'/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'.

P a u l
A: 

I have no idea what the couse of the problem is. If anyone knows I would be interested find out!

I have a workaround though which solved it for me:

  1. Remove the reference from the Silverlight project to whatever is using log4net
  2. Remove that project using log4net from the solution.
  3. Reload the XAML-pages and save the solution.
  4. Finally add the project using log4net and the reference again.

    Henrik