gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 13:48:34 26 4
gpt4 key购买 nike

此 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' 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)

最佳答案

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

关于WPF:加载资源字典时的 XamlParseException -> AccessViolation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4082110/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com