Silverlight for WP7 中的 FileNotFoundException

8

文件或程序集名称 'System.Windows.debug.resources, Version=2.0.5.0, Culture=en-US, PublicKeyToken=7cec85d7bea7798e' 或其依赖项之一未找到。

我相信这是因为某些文件没有正确安装,因为该异常在各种情况下都会发生。可能是一个包含异常名称的文件。

有人知道是否可以重新安装它或类似的操作吗?

它发生在没有反汇编的地方。

调用堆栈位置

mscorlib.dll!System.ThrowHelper.throwVersion37CompatException(System.ExceptionType newEType = FileNotFoundException, string newString = "File or assembly name 'System.Windows.debug.resources, Version=2.0.5.0, Culture=en-US, PublicKeyToken=7cec85d7bea7798e', or one of its dependencies, was not found.", System.ExceptionType oldEType = IOException, string oldString = "File or assembly name 'System.Windows.debug.resources, Version=2.0.5.0, Culture=en-US, PublicKeyToken=7cec85d7bea7798e', or one of its dependencies, was not found.") + 0x19 bytes  

完整异常详情

System.IO.FileNotFoundException occurred
  Message=File or assembly name 'System.Windows.debug.resources, Version=2.0.5.0, Culture=en-US, PublicKeyToken=7cec85d7bea7798e', or one of its dependencies, was not found.
  StackTrace:
       at System.ThrowHelper.throwVersion37CompatException(ExceptionType newEType, String newString, ExceptionType oldEType, String oldString)
       at System.Reflection.Assembly.Load(String assemblyString)
       at System.Windows.Resx..ctor()
       at System.Windows.Resx.GetLoader()
       at System.Windows.Resx.GetStringHelper(String name)
       at System.Windows.Resx.GetString(String name)
       at System.Windows.PropertyAccessPathStep.ConnectToPropertyInSource(Boolean isSourceCollectionViewCurrentItem)
       at System.Windows.PropertyAccessPathStep.ConnectToProperty()
       at System.Windows.PropertyAccessPathStep.ReConnect(Object newSource)
       at System.Windows.PropertyPathListener.ReConnect(Object source)
       at System.Windows.Data.BindingExpression.SourceAcquired()
       at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e)
       at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e)
       at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e)
       at System.Windows.FrameworkElement.OnAncestorDataContextChanged(DataContextChangedEventArgs e)
       at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e)
       at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)
       at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)
       at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)
       at MS.Internal.XcpImports.Measure_WithDesiredSizeNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       at MS.Internal.XcpImports.UIElement_Measure_WithDesiredSize(UIElement element, Size availableSize)
       at System.Windows.UIElement.Measure_WithDesiredSize(Size availableSize)
       at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(UIElement child, Size layoutSlotSize)
       at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
       at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
       at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
       at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
       at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
       at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
       at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       at Microsoft.Phone.Controls.PhoneApplicationFrame.MeasureOverride(Size availableSize)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

1
我已经看到这种情况几次了(如果我的记忆没有出错),这不是一个关键的异常,也不会停止应用程序的执行;只需按F5继续执行即可。 - Derek Lakin
我在 MSDN 论坛上读到这是一个已知的 bug,他们正在尝试修复。所以按照 Derek 的建议去做。我会尝试为你找到论坛帖子,并尝试在今天晚些时候发布它。 - invalidusername
感谢您的努力。请将其发布为答案,以便我可以关闭问题。 - SBoss
1
微软上个月正式停止了对WP7的所有支持,因此这个问题将永远不会在WP7上得到修复。 - Cœur
4个回答

4

MSDN上的答案是四月份的,你知道是否已经提供了修复程序吗? - thomasmartinsen
@invalidusername 链接已失效:您未被授权执行此操作。 - Cœur
希望这个问题已经解决了,因为它是3年前发布的。如果可能的话,请发布一些额外的信息。我不确定还有多少WP7设备存在,但您最好还是针对WP8进行开发。 - invalidusername

2
有一个简单的解决方法,只需创建自定义的CheckBox控件,通过继承Windows Phone Silverlight CheckBox并覆盖ToString()方法即可,如下所示:
public class MyCheckBox:CheckBox 
{ 
    public override string ToString() 
    { 
        return string.Empty; 
    } 
}

点击此处查看更多信息:Windows Phone框架异常处理。


它有所帮助,但我们仍然在 System.Windows.dll!System.Net.Browser.ClientHttpWebRequest.Completed(object sender, System.EventArgs e) 上遇到了 Resx.GetString() 异常,就像在这个 StackOverflow 问题中描述的那样。 - Cœur

2
你是否百分之百确定你以正常的“应用程序崩溃”的方式遇到了这个异常?我经常遇到这种情况,但只有在VisualStudio的Debug->Exceptions菜单选项中设置System.IO.FileNotFound或System.IO.IsolatedStorage异常拦截器时才会出现。
需要注意的是,在WP7上,异常拦截器会捕获与所选类型匹配的每一个抛出的异常,即使它已被正确处理。这就是为什么我看到它们,我经常使用这些拦截器来调试自己的代码。也许你也激活了它们,只是忘记了吗?

0
每当Visual Studio 2010尝试在XAML数据值转换期间(即通过数据绑定表达式指定的IValueConverter处理)格式化错误消息时,我就会遇到这种情况。
我发现的解决方法是在调试器中断点,双击堆栈跟踪条目中的2或3个级别,然后查看“本地”窗口以查看它正在尝试格式化的错误消息和绑定表达式的参数。
您应该能够从中找出问题所在,例如,可能是绑定表达式路径部分中的拼写错误(属性名称错误/源不存在)或不受支持的转换(未指定值转换器且默认转换不受支持)。
用户“invalidusername”提供的MSDN链接不再起作用(似乎已从新的“Metro”样式Dev Center网站中删除),因此我无法检查是否有任何其他已知的解决方法或修复程序。这确实应该在MS Connect上记录。但是,Windows Phone 8 SDK即将推出(目前传言为9月12日),因此我想我们应该等待并观察VS 2012和新SDK的运行情况(假设它仍然支持OS 7.1手机!)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接