仅在VS 2010上运行时:COMException:灾难性故障:错误代码:-2147418113

时间:2011-02-03 23:42:30

标签: c# visual-studio-2010 .net-4.0

我遇到了这个错误:在尝试使用.Net Framework 4.0中的旧DLL时 如果我将项目目标类型更改为3.5,则不会出现错误 奇怪的是,所有这一切都发生在VS 2010内部运行时。如果我从Windows资源管理器运行可执行文件,则3.5和4.0中不会出现问题。 好像vshost中的一些bug? VS 2010 Express,或.net框架?

更新:此BUG仅发生在WPF独立应用程序上,如果将其更改为XBAP WPF我可以使用dll而不会出现更大问题,只有一条消息告诉它无法停止调试。

我将在此处打开此问题,等待查看connect.microsoft.com上有关此票证的进展情况。

有没有办法让我的.net4 app.config使用.net 3.5加载这个特定的dll(CobreBemX.dll)?

我认为这是一些错误,然后我将其提交给https://connect.microsoft.com/VisualStudio/feedback/details/636697/comexception-was-unhandled-catastrophic-failure

以下是抛出COMException的代码:

//Cria instância do objeto CobreBemX
CobreBemX.ContaCorrente _CobreBemX = new CobreBemX.ContaCorrenteClass();
//Monta arquivo de licença de teste para banco 001 carteira 18
_CobreBemX.ArquivoLicenca = @"C:\CobreBemX\Exemplos\Licencas\237-09.conf"; // THIS LINES CAUSES THE PROBLEM ON .NET 4.0    IF I CHANGE TARGET FRAMEWORK TO 3.5  NO PROBLEM HAPPENS

这是堆栈跟踪:

System.Runtime.InteropServices.COMException was unhandled
  Message=Falha catastrófica
  Source=CobreBemX.ContaCorrente
  ErrorCode=-2147418113
  StackTrace:
       at CobreBemX.ContaCorrenteClass.set_ArquivoLicenca(String Value)
       at EmissorBoletosWindows.MainWindow.button1_Click(Object sender, RoutedEventArgs e) in C:\inetpub\wwwroot\CRM\Cobranca\EmissorBoletosWindows\EmissorBoletosWindows\MainWindow.xaml.cs:line 90
       at EmissorBoletosWindows.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e) in C:\inetpub\wwwroot\CRM\Cobranca\EmissorBoletosWindows\EmissorBoletosWindows\MainWindow.xaml.cs:line 39
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
       at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
       at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
       at MS.Internal.LoadedOrUnloadedOperation.DoWork()
       at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
       at System.Windows.Interop.HwndTarget.OnResize()
       at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Window.ShowHelper(Object booleanBox)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at EmissorBoletosWindows.App.Main() in C:\inetpub\wwwroot\CRM\Cobranca\EmissorBoletosWindows\EmissorBoletosWindows\obj\x86\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

2 个答案:

答案 0 :(得分:1)

如果检查堆栈的顶部,该方法建议库正在执行某些软件许可处理。我的猜测(并且它猜测)是库正在使用可执行文件的名称和路径来定位许可证,并且因为应用程序正在通过VSHost运行,这是失败的,导致表达的错误作为COM例外。

在VSHost之外它工作得很好的事实会给这个问题增加不少。您可以使用FileMon之类的工具来查看它在哪里绊倒。

答案 1 :(得分:0)

目前除了使用XBAP

之外没有任何解决方案