【发布时间】:2010-11-03 16:14:47
【问题描述】:
我创建了一个 .NET 4 桌面应用程序,它可以在各种基于 Windows-7 的 PC 上很好地运行,无论是否安装了 Visual Studio。目标 PC 需要具有 .NET Framework 4 客户端配置文件和扩展配置文件。
但是,当我尝试在安装了 .NET 4 的 Vista PC 上运行相同的应用程序(这是我拥有的唯一一台装有 Vista 的 PC,我没有检查过其他 PC,因此 Vista 可能不是罪魁祸首)时,我得到了这个异常,我无法弄清楚:
Exception object: 01dc1bb4
Exception type: System.BadImageFormatException
Message: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The module was expected to contain an assembly manifest.
InnerException: System.BadImageFormatException, Use !PrintException 01dc25d8 to see more.
StackTrace (generated):
SP IP Function
0029E264 6F98249A mscorlib_ni!System.ModuleHandle.ResolveMethodHandleInternalCore(System.Reflection.RuntimeModule, Int32, IntPtr[], Int32, IntPtr[], Int32)+0x8a
0029E29C 6F97B4E2 mscorlib_ni!System.ModuleHandle.ResolveMethodHandleInternal(System.Reflection.RuntimeModule, Int32, System.RuntimeTypeHandle[], System.RuntimeTypeHandle[])+0x42
0029E2C4 6F97AFFF mscorlib_ni!System.Reflection.CustomAttributeData..ctor(System.Reflection.RuntimeModule, System.Reflection.CustomAttributeRecord)+0x37
0029E448 6F97AF97 mscorlib_ni!System.Reflection.CustomAttributeData.GetCustomAttributes(System.Reflection.RuntimeModule, Int32)+0x53
0029E464 6F97C887 mscorlib_ni!System.Reflection.CustomAttributeData.GetCustomAttributesInternal(System.Reflection.RuntimeAssembly)+0x47
0029E480 6F97C825 mscorlib_ni!System.Reflection.RuntimeAssembly.GetCustomAttributesData()+0x5
0029E484 6F97C815 mscorlib_ni!System.Reflection.CustomAttributeData.GetCustomAttributes(System.Reflection.Assembly)+0x21
0029E490 6F97C5C9 mscorlib_ni!System.Resources.ManifestBasedResourceGroveler.GetNeutralResourcesLanguage(System.Reflection.Assembly, System.Resources.UltimateResourceFallbackLocation ByRef)+0x31
0029E4DC 6F97C515 mscorlib_ni!System.Resources.ResourceManager.CommonSatelliteAssemblyInit()+0x6d
0029E4F8 6F97C439 mscorlib_ni!System.Resources.ResourceManager..ctor(System.String, System.Reflection.Assembly)+0x51
0029E510 009CF7DB Microsoft_Practices_Composite_ba0000!Microsoft.Practices.Composite.Properties.Resources.get_ResourceManager()+0x9b
0029E53C 009CF700 Microsoft_Practices_Composite_ba0000!Microsoft.Practices.Composite.Properties.Resources.get_DefaultTextLoggerPattern()+0x20
0029E550 009CF585 Microsoft_Practices_Composite_ba0000!Microsoft.Practices.Composite.Logging.TextLogger.Log(System.String, Microsoft.Practices.Composite.Logging.Category, Microsoft.Practices.Composite.Logging.Priority)+0x35
0029E5CC 009CF359 Microsoft_Practices_Composite_UnityExtensions_b70000!Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean)+0x99
0029E624 009CF2A4 Microsoft_Practices_Composite_UnityExtensions_b70000!Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run()+0x24
0029E630 009CF054 iToldem!ClientBootstrapper.App.OnStartup(System.Windows.StartupEventArgs)+0x54
0029E648 009CEF43 PresentationFramework_4310000!System.Windows.Application.<.ctor>b__1(System.Object)+0x33
0029E658 009CC04D WindowsBase_4a00000!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)+0xfd
0029E67C 009CBED0 WindowsBase_4a00000!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)+0x40
0029E6C4 009CBAC6 WindowsBase_4a00000!System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate, System.Object, Int32, System.Delegate)+0x36
0029E6E4 009CEE4D WindowsBase_4a00000!System.Windows.Threading.DispatcherOperation.InvokeImpl()+0x5d
0029E714 009CEDD9 WindowsBase_4a00000!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)+0x29
0029E71C 6F974DB5 mscorlib_ni!System.Threading.ExecutionContext.runTryCode(System.Object)+0x51
0029EBC0 6F974CBA mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x6a
0029EBD8 6F977FC2 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+0x7e
0029EBFC 6F977F34 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x2c
0029EC18 009CED00 WindowsBase_4a00000!System.Windows.Threading.DispatcherOperation.Invoke()+0x50
0029EC54 009CE8B7 WindowsBase_4a00000!System.Windows.Threading.Dispatcher.ProcessQueue()+0x1a7
0029EC94 009CE5D4 WindowsBase_4a00000!System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)+0x64
0029ECE8 009CC253 WindowsBase_4a00000!MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)+0xb3
0029ED34 009CC17F WindowsBase_4a00000!MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)+0x6f
0029ED44 009CC04D WindowsBase_4a00000!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)+0xfd
0029ED68 009CBED0 WindowsBase_4a00000!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)+0x40
0029EDB0 009CBAC6 WindowsBase_4a00000!System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate, System.Object, Int32, System.Delegate)+0x36
0029EDD0 009CB82B WindowsBase_4a00000!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)+0x8b
0029EE18 009CB29F WindowsBase_4a00000!MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)+0x19f
0029EFE4 009CDFBB WindowsBase_4a00000!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)+0xab
0029F034 009CDE2E WindowsBase_4a00000!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)+0x2e
0029F040 009CDD5A PresentationFramework_4310000!System.Windows.Application.RunDispatcher(System.Object)+0x2a
0029F04C 009CD987 PresentationFramework_4310000!System.Windows.Application.RunInternal(System.Windows.Window)+0x167
0029F060 009CD67A PresentationFramework_4310000!System.Windows.Application.Run(System.Windows.Window)+0x2a
0029F070 009CD62F PresentationFramework_4310000!System.Windows.Application.Run()+0x5f
0029F07C 009C00B1 MyApplication!ClientBootstrapper.App.Main()+0x41
StackTraceString: <none>
HResult: 80131018
我的问题是:
- 这可能是什么问题?
- 这不是我第一次遇到“无法加载文件或程序集”的问题,我一直在黑暗中猜测为什么会发生这种情况以及如何解决。上次它是在 Debug 中编译的非托管 C++ DLL,不会在客户端 PC 上运行。如何获得有关问题确切性质的更多信息?
- 由于我怀疑 .NET 安装有问题,有没有办法验证 .NET 安装是否正确?
其他信息: 我已经编译了一个简单的控制台应用程序和一个简单的 WPF 应用程序,它们都在目标 PC 上运行良好,这让我相信我的原始应用程序是罪魁祸首 - 但我怎样才能找到它?
编辑:问题最终通过完全卸载 .NET 4 并重新安装得到解决。奇怪的是,尽管安装并不好,但大多数 .NET 应用程序实际上都能正常工作。
【问题讨论】:
标签: .net dependencies