我試圖調用是從Delphi應用程序在這裏呼叫WPF的Windows COM從內Delphi應用程序
Is it possible to package WPF window as COM Object
描述一個COM對象。
導入tlb後,我使用此代碼來調用該COM對象。
var
y: ITestWpfInterface;
begin
y:=CreateComObject(CLASS_TestWpfInterface) as ITestWpfInterface;
y.TestWpf();
end;
COM對象被實例化並調用該方法。 但COM對象崩潰Delphi應用程序中,當到達
Window1 form = new Window1();
線。當我試圖從word-VBA做同樣的wpf窗口顯示。
Sub test()
Dim x As New WpfControlLibrary1.TestWpfInterface
x.TestWpf
End Sub
圍繞新窗口的catch塊不會顯示任何異常。 我已用windbg調試應用程序。它顯示了一個由0異常的div,加載框架後wpf程序集的
爲什麼delphi應用程序崩潰?是什麼導致了這次事故如何解決它?
編輯: 這是WinDbg的
ModLoad: 76330000 7634d000 C:\WINDOWS\system32\IMM32.DLL
ModLoad: 5b0f0000 5b128000 c:\windows\system32\uxtheme.dll
ModLoad: 75250000 7527e000 C:\WINDOWS\system32\msctfime.ime
ModLoad: 76f90000 7700f000 C:\WINDOWS\system32\CLBCATQ.DLL
ModLoad: 77010000 770e3000 C:\WINDOWS\system32\COMRes.dll
ModLoad: 79000000 7904a000 C:\WINDOWS\system32\mscoree.dll
ModLoad: 603b0000 60417000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
ModLoad: 76970000 76a21000 C:\WINDOWS\system32\sxs.dll
ModLoad: 79140000 797ae000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
ModLoad: 79060000 7911e000 C:\WINDOWS\system32\MSVCR100_CLR0400.dll
ModLoad: 77f40000 77fb6000 C:\WINDOWS\system32\SHLWAPI.dll
(2b4.244): Unknown exception - code 04242420 (first chance)
ModLoad: 79880000 7a641000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\a774bd593b8420bae4a8cf1d46af3ba2\mscorlib.ni.dll
ModLoad: 60340000 6034d000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\culture.dll
ModLoad: 60930000 60940000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\nlssorting.dll
ModLoad: 03270000 03549000 C:\WINDOWS\system32\xpsp2res.dll
ModLoad: 79810000 79870000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clrjit.dll
ModLoad: 7a830000 7b0dd000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System\5286fe2d0167eb835a9f11025f1cb756\System.ni.dll
ModLoad: 58c20000 58fd1000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\WindowsBase\9dacf8a5033dfbcb435be166d2f42cdf\WindowsBase.ni.dll
ModLoad: 68000000 68036000 C:\WINDOWS\system32\rsaenh.dll
ModLoad: 55590000 5607d000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\PresentationCore\8244412387a82c0acd3d63622e22cef5\PresentationCore.ni.dll
ModLoad: 56980000 57aad000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\PresentationFramewo#\813a0913bea1269e48613509609e72b4\PresentationFramework.ni.dll
ModLoad: 561c0000 562a1000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\wpftxt_v0400.dll
ModLoad: 55000000 5519a000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\wpfgfx_v0400.dll
ModLoad: 554c0000 55585000 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationNative_v0400.dll
ModLoad: 59200000 593b5000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System.Xaml\a3ffdc1316821b5ceb32c9a788334329\System.Xaml.ni.dll
ModLoad: 60c90000 60d83000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System.Configuration\4844dd28e0611d1ebd1e449fe822c2a5\System.Configuration.ni.dll
ModLoad: 69760000 69cbe000 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System.Xml\419103071a5a5d17738afbe9dd03d58a\System.Xml.ni.dll
(2b4.244): Unknown exception - code c0000090 (first chance)
(2b4.244): Unknown exception - code c0000090 (first chance)
(2b4.244): Unknown exception - code c0000090 (first chance)
eax=000000c0 ebx=00007530 ecx=001b1e30 edx=00000020 esi=00000000 edi=0374ff50
eip=7c91e514 esp=0374ff20 ebp=0374ff78 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
ntdll!KiFastSystemCallRet:
7c91e514 c3 ret
的這個問題,包括示例代碼德語版本可以發現這裏的輸出: http://www.delphipraxis.net/166199-com-interop-mit-einer-c-library-mit-wpf-und-com.html
你嘗試導入COM對象作爲一個組件在delphi? – whosrdaddy 2012-02-02 13:35:06
我嘗試了早期和晚期綁定。這兩個應用程序崩潰。崩潰=即時關閉德爾福應用程序。 – 2012-02-02 13:58:49
沒有註冊com對象與regasm它不可能得到對象的一個實例。 regasm也被用來產生tlb。這個tlb被導入到delphi中。 一切都很好,除了dotnet創建wpf窗口。 – 2012-02-03 15:01:16