【问题标题】:WPF: XamlParseException -> AccessViolation when loading a resource dictionaryWPF:加载资源字典时的 XamlParseException -> AccessViolation
【发布时间】:2010-11-02 21:07:17
【问题描述】:

此 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 请求,内容类型和内容类型)在 System.Windows.ResourceDictionary.set_Source(Uri value) --- 结束 内部异常堆栈跟踪 --- 在 System.Windows.Markup.XamlParseException.ThrowException(字符串 消息,异常 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,字符串消息, 异常innerException)在 System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(字符串 消息,异常 innerException)在 System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(字符串 attribValue, Int16 attributeId, Int16 converterTypeId) 在 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, Object parent, Boolean closeStream) at System.Windows.Application.LoadComponent(对象组件,Uri 资源定位器)在 Symform.Node.Configuration.MainWindowView.InitializeComponent() 在 Symform.Node.Configuration.MainWindowView..ctor() 在 Symform.Node.Configuration.App.OnStartup(StartupEventArgs e) 在 System.Windows.Application.<.ctor>b__0(对象未使用)在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托 回调,对象参数,布尔 isSingleParameter) 在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源, 委托回调,对象参数,布尔 isSingleParameter,委托 catchHandler)

【问题讨论】:

    标签: wpf access-violation resourcedictionary xamlparseexception


    【解决方案1】:

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

    【讨论】:

    • 感谢您的建议。我确认 BuildAction 已经设置为 Page,所以这似乎没有解决这个特定问题。
    【解决方案2】:

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

    【讨论】:

    • 我昨天遇到了同样的问题,但我必须卸载 3.5、3.0 和 2.0,然后重新安装 3.5。很奇怪。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    相关资源
    最近更新 更多