2009-04-14 28 views
2

我得到下面的異常裝載任何的XAML在我的項目:怪異的Silverlight設計錯誤

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

的堆棧跟蹤表明你沒有在你的項目到指定的log4net程序集的引用。解決方法是添加一個對它的引用,但是除非你得到一個已經針對Silverlight agCLR運行時編譯的log4net程序集,否則你將無法做到。

如果您不想在您的Silverlight應用程序中使用log4net,則另一種方法是刪除嘗試使用它的代碼段。再次從堆棧跟蹤看來,您似乎正在設置一些初始化log4net的資源。嘗試打開您的Windox.xaml並查看資源部分。如果您看到log4net的任何跡象,請將其移除並查看是否有幫助。

+0

我的解決方案使用log4net的。我的項目沒有,我不能參考log4net,因爲我的程序集沒有針對Silverlight運行時編譯。再次,這是自動生成的「新silverlight項目」,它會在設計器中引發此錯誤... – 2009-04-14 03:41:48

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;組件/ MS/Internal/Designer/PropertyEditing/Resources/StylesCore.xaml'中的對象'ResourceDictionary_2'出錯。

0

我不知道問題的癥結在哪裏。如果有人知道我會有興趣瞭解一下!

我有一個解決辦法,雖然這解決了這個問題對我來說:

  1. 取下Silverlight項目無論是使用log4net的
  2. 以參考使用刪除log4net的從解決方案項目。
  3. 重新加載XAML頁面並保存解決方案。
  4. 最後再次使用log4net和引用添加項目。

    亨裏克