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

发布于 2024-09-30 08:09:20 字数 2963 浏览 0 评论 0原文

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

我不知道如何看待我所看到的这个例外。同一个 exe 已经在所有机器上运行了几个月,但就在今天,一位客户遇到了这个问题。我无法在本地重现它,我所要做的就是下面日志文件中的堆栈跟踪。

我使用 Visual Studio 2010 制作了一个快速示例应用程序,该应用程序仅在窗口中显示一个按钮,该按钮内容字符串是从资源字典中提取的。这在客户的机器上有效,所以看起来 .NET 安装并没有完全在那里...

关于下一步要调查或研究什么有什么想法吗?也许客户.NET安装的某些状态?

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

错误:

System.Windows.Markup.XamlParseException: “MainWindowViewResources.xaml”值无法分配给属性 对象“System.Windows.ResourceDictionary”的“源”。试图 读或写受保护的内存。这通常表明其他 内存已损坏。对象错误 标记文件中的“System.Windows.ResourceDictionary” 'symformconfig;组件/视图/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&内容类型)位于 System.Windows.ResourceDictionary.set_Source(Uri value) --- 结束 内部异常堆栈跟踪 --- at System.Windows.Markup.XamlParseException.ThrowException(字符串 消息,异常innerException,Int32 lineNumber,Int32 linePosition、Uri baseUri、XamlObjectIds currentXamlObjectIds、 XamlObjectIds contextXamlObjectIds,类型 objectType) at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext,Int32 lineNumber,Int32 linePosition,字符串消息, 异常内部异常)在 System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(字符串 消息,异常innerException)在 System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(字符串 attribValue、Int16 attributeId、Int16 converterTypeId) at System.Windows.Markup.BamlRecordReader.ReadPropertyConverterRecord(BamlPropertyWithConverterRecord bamlPropertyRecord)位于 System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord) 在 System.Windows.Markup.BamlRecordReader.Read(Boolean 单记录)在 System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment() 在 System.Windows.Markup.TreeBuilder.Parse() 在 System.Windows.Markup.XamlReader.LoadBaml(流流,ParserContext parserContext、对象父级、布尔值 closeStream) at System.Windows.Application.LoadComponent(对象组件,Uri 资源定位器)位于 Symform.Node.Configuration.MainWindowView.InitializeComponent() 在 Symform.Node.Configuration.MainWindowView..ctor() 位于 Symform.Node.Configuration.App.OnStartup(StartupEventArgs e) at System.Windows.Application.<.ctor>b__0(对象未使用)位于 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托 回调、对象参数、布尔值 isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源, 委托回调、对象参数、布尔 isSingleParameter、委托 catchHandler)

This WPF app targets .NET 3.5 and is built with the 4.0 tools from Visual Studio 2010 (csc.exe version is 4.0.30319.1).

I'm not sure what to make of this exception I'm seeing. The same exe has been working for months on all machines, but just today a customer ran into this. I'm unable to repro it locally, all I have to go on is the stack trace from our log files below.

I made a quick sample application with Visual Studio 2010 that just shows a button in a Window, the button Content string being pulled from a resource dictionary. This worked on the customers machine, so it appears the .NET installation isn't completely hosed there...

Any ideas on what to investigate or look into next? Maybe some state of the customers .NET install??

EDIT: The customer performed an uninstall and reinstall of .NET 3.5 and that fixed the issue. I guess there was some weird state in their installation that was causing this issue.

The error:

System.Windows.Markup.XamlParseException:
'MainWindowViewResources.xaml' value cannot be assigned to property
'Source' of object 'System.Windows.ResourceDictionary'. Attempted to
read or write protected memory. This is often an indication that other
memory is corrupt. Error at object
'System.Windows.ResourceDictionary' in markup file
'symformconfig;component/view/mainwindowview.xaml'. --->
System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
at System.IO.Packaging.PackagePart.CleanUpRequestedStreamsList() at
System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess
access) at
System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream() at
System.IO.Packaging.PackWebResponse.get_ContentType() at
MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse response)
at MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest
request, ContentType& contentType) at
System.Windows.ResourceDictionary.set_Source(Uri value) --- End of
inner exception stack trace --- 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.LoadComponent(Object component, Uri
resourceLocator) at
Symform.Node.Configuration.MainWindowView.InitializeComponent() at
Symform.Node.Configuration.MainWindowView..ctor() at
Symform.Node.Configuration.App.OnStartup(StartupEventArgs e) at
System.Windows.Application.<.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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

诗化ㄋ丶相逢 2024-10-07 08:09:20

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

Make sure that the BuildAction of MainWindowViewResources.xaml is set to Page and not Resource. You can find that setting in the Properties panel.

极致的悲 2024-10-07 08:09:20

客户卸载并重新安装 .NET 3.5,解决了该问题。我猜他们的安装中有一些奇怪的状态导致了这个问题。

The customer performed an uninstall and reinstall of .NET 3.5 and that fixed the issue. I guess there was some weird state in their installation that was causing this issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文