3

此WPF應用程序以.NET 3.5爲目標,並使用Visual Studio 2010中的4.0工具(csc.exe版本爲4.0.30319.1)構建。WPF:XamlParseException - > AccessViolation加載資源字典時

我不知道該看到的例外情況。所有機器上的相同exe已經工作了數月,但就在今天,一位客戶遇到了這個問題。我無法在本地複製它,我只需要從下面的日誌文件中獲取堆棧跟蹤信息。

我用Visual Studio 2010做了一個快速示例應用程序,它只是在窗口中顯示一個按鈕,從資源字典中提取按鈕Content字符串。這在客戶機器上工作,所以它看起來.NET安裝不完全在那裏...

什麼調查或調查未來的任何想法?也許某些客戶的.NET安裝狀態?

編輯:客戶執行卸載並重新安裝的.NET 3.5,並解決了這個問題。我猜在他們的安裝中有一些奇怪的狀態導致了這個問題。

System.Windows.Markup.XamlParseException:'MainWindowViewResources.xaml'值不能分配給對象'System.Windows.ResourceDictionary'的屬性'Source'。嘗試讀取或寫入受保護的內存。這通常表明其他內存已損壞。標記文件'symformconfig; component/view/mainwindowview.xaml'中的對象'System.Windows.ResourceDictionary'出錯。 ---> System.AccessViolationException:試圖讀取或寫入受保護的內存。這通常表明其他內存已損壞。 在System.IO.Packaging.PackagePart.CleanUpRequestedStreamsList() 在System.IO.Packaging.PackagePart.GetStream(的FileMode模式,FileAccess的訪問) 在System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream() 在系統。 IO.Packaging.PackWebResponse.GetResponseStream() 在System.IO.Packaging.PackWebResponse.get_ContentType() 在MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse的響應) 在MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest的請求,的ContentType & contentType) at System.Windows.ResourceDictionary.set_Source(Uri value) ---內部異常堆棧跟蹤結束--- 在System.Windows.Markup.XamlParseExcepti on.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消息,Exception ExceptionException) 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 Syste 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)在Symform.Node.Configuration的Symform.Node.Configuration.MainWindowView.InitializeComponent() 上的System.Windows.Application.LoadComponent(對象組件,Uri resourceLocator) 。 MainWindowView..ctor() 位於Symform.Node.Configuration.App。在System.Windows.Application的OnStartup(StartupEventArgs e) 。 < .ctor> b__0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback,Object args,Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback,Object args ,Boolean isSingleParameter,Delegate catchHandler)

回答

1

客戶執行了卸載並重新安裝.NET 3.5,並解決了問題。我猜在他們的安裝中有一些奇怪的狀態導致了這個問題。

+1

我昨天有同樣的問題,但我不得不卸載3.5,3.0和2.0,然後重新安裝3.5。很奇怪。 – 2010-11-09 14:31:12

1

確保MainWindowViewResources.xaml的BuildAction設置爲Page而不是Resource。您可以在「屬性」面板中找到該設置。

+0

感謝您的意見。我證實BuildAction已經被設置爲Page,所以似乎沒有解決這個特殊問題。 – JBW976 2010-11-09 01:49:10