2011-02-03 98 views
2

我被這個錯誤卡住了:試圖在.Net Framework 4.0中使用舊的DLL
如果我將項目目標類型更改爲3.5,沒有錯誤出現。
奇怪的是,所有這一切發生只在VS 2010中運行。如果我從Windows資源管理器運行可執行文件,3.5和4.0中沒有發生任何問題。 似乎vshost中的一些錯誤? VS 2010 Express或.net框架?只有在VS 2010上運行時:COMException:災難性失敗:錯誤代碼:-2147418113

更新:此BUG只發生在WPF獨立應用程序上,如果將其更改爲XBAP WPF我可以使用dll而沒有更大的問題,只有一條消息告訴它不能停止調試。

我會在此處打開此問題,等待connect.microsoft.com上有關此票證的進展情況。

有沒有辦法讓我的.net4 app.config使用.net 3.5加載這個特定的dll(CobreBemX.dll)?

我認爲這是一些bug,然後我提交給了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: 
+1

我們能否獲得更多信息?就像可能圍繞引發異常的代碼和/或堆棧跟蹤一樣?什麼是「舊DLL」?它是一個COM組件嗎?它寫了什麼語言?你有源代碼嗎? – 2011-02-03 23:48:33

+0

舊的DLL是第三部分,我不知道它寫了什麼。我認爲這是一個COM組件。 – Tony 2011-02-04 00:12:23

回答

0

現在除了使用XBAP以外,沒有其他解決方案使用XBAP

1

如果您檢查堆棧的頂部,該方法建議庫正在執行一些軟件許可處理。我的猜測(猜測)是庫使用可執行文件的名稱和路徑來定位許可證,並且由於應用程序正在通過VSHost運行,所以這是失敗導致的錯誤,表示爲COM異常。

它在VSHost以外的工作狀況很好,這一點很重要。您可以使用諸如FileMon之類的工具來查看它正在跳閘的位置。