这个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'的属性'Source'。尝试读取或写入受保护的内存,这通常意味着其他内存已损坏。在标记文件'symformconfig;component/view/mainwindowview.xaml'中的对象'System.Windows.ResourceDictionary'出现错误。---> System.AccessViolationException:尝试读取或写入受保护的内存,这通常意味着其他内存已损坏。在System.IO.Packaging.PackagePart.CleanUpRequestedStreamsList()处 at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access) 在System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()处 at System.IO.Packaging.PackWebResponse.GetResponseStream() 在System.IO.Packaging.PackWebResponse.get_ContentType()处 at MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse response) 在MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest request, ContentType& contentType)处 at System.Windows.ResourceDictionary.set_Source(Uri value) --- 内部异常堆栈跟踪结尾 --- 在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) 在System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)处 在System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(String 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 singleRecord)处 在System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()处 在System.Windows.Markup.TreeBuilder.Parse()处 在System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)处 在System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)处 在Symform.Node.Configuration.MainWindowView.InitializeComponent()处 在Symform.Node.Configuration.MainWindowView..ctor()处 在Symform.Node.Configuration.App.OnStartup(StartupEventArgs e)处 在System.Windows.Application.<.ctor>b__0(Object unused)处 在System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)处 在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)处