WPF:XamlParseException->加载资源字典时的AccessViolation

问题描述 投票:3回答:2

此WPF应用程序针对.NET 3.5,并使用Visual Studio 2010中的4.0工具构建(csc.exe版本为4.0.30319.1)。

我不确定我要怎么处理这个异常。相同的exe在所有机器上已经工作了几个月,但是直到今天,一位客户才遇到了这个问题。我无法在本地对其进行复制,我要做的就是从下面的日志文件中获取堆栈跟踪信息。

我使用Visual Studio 2010创建了一个快速示例应用程序,该应用程序仅在Window中显示一个按钮,该按钮的内容字符串是从资源字典中提取的。这可以在客户计算机上正常工作,因此.NET安装似乎并没有完全安装在那里...

关于调查或下一步研究的任何想法?可能是某些状态的.NET客户安装?

编辑:客户执行了.NET 3.5的卸载和重新安装,从而解决了该问题。我猜他们的安装中有些奇怪的状态导致了此问题。

错误:

System.Windows.Markup.XamlParseException:无法将“ MainWindowViewResources.xaml”值分配给属性对象“ System.Windows.ResourceDictionary”的“源”。尝试做读取或写入受保护的内存。这通常表明其他内存已损坏。对象错误标记文件中的“ System.Windows.ResourceDictionary”'symformconfig; component / view / mainwindowview.xaml'。 ->System.AccessViolationException:尝试读取或写入受保护记忆。这通常表明其他内存已损坏。在System.IO.Packaging.PackagePart.CleanUpRequestedStreamsList()在System.IO.Packaging.PackagePart.GetStream(FileMode模式,FileAccess访问)System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()在System.IO.Packaging.PackWebResponse.GetResponseStream()处System.IO.Packaging.PackWebResponse.get_ContentType()在MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse响应)在MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest请求,ContentType&contentType)System.Windows.ResourceDictionary.set_Source(Uri值)-结束内部异常堆栈跟踪---System.Windows.Markup.XamlParseException.ThrowException(字符串消息,异常innerException,Int32 lineNumber,Int32linePosition,Uri baseUri,XamlObjectIds currentXamlObjectIds,XamlObjectIds contextXamlObjectIds,类型为objectType),位于System.Windows.Markup.XamlParseException.ThrowException(ParserContextparserContext,Int32 lineNumber,Int32 linePosition,字符串消息,异常innerException)在System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String消息,异常innerException)在System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(StringattribValue,Int16 attributeId,Int16 converterTypeId)System.Windows.Markup.BamlRecordReader.ReadPropertyConverterRecord(BamlPropertyWithConverterRecordbamlPropertyRecord)在System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecordbamlRecord)在System.Windows.Markup.BamlRecordReader.Read(布尔singleRecord)System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()位于System.Windows.Markup.TreeBuilder.Parse()位于System.Windows.Markup.XamlReader.LoadBaml(流流,ParserContextparserContext,对象父级,布尔型closeStream)位于System.Windows.Application.LoadComponent(对象组件,UriresourceLocator)位于Symform.Node.Configuration.MainWindowView.InitializeComponent()在Symform.Node.Configuration.MainWindowView..ctor()在Symform.Node.Configuration.App.OnStartup(StartupEventArgs e)在System.Windows.Application。 b__0(未使用对象)位于System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,布尔值isSingleParameter)System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象参数,布尔值isSingleParameter,委托catchHandler)

wpf access-violation resourcedictionary xamlparseexception
2个回答
1
投票

请确保MainWindowViewResources.xaml的BuildAction设置为Page而不是Resource。您可以在“属性”面板中找到该设置。


1
投票

客户执行了.NET 3.5的卸载和重新安装,从而解决了该问题。我猜他们的安装中有些奇怪的状态导致了此问题。

© www.soinside.com 2019 - 2024. All rights reserved.