Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tlbimp Failed Generating Interop Dll

I have developed a COM library in Delphi. When I try to "add reference" in a Visual Studio project, VS crashes. I tried to build Interop assembly by tlbimp.exe and it failed with:

TlbImp : error TI1000 : The type library importer encountered an unexpected exception: System.AccessViolationException - Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Interestingly when I "add reference" to a Web Application (or a Web Site) project, it successfully generates Interop dll and adds the reference.

It is important to me to know how tlbimp.exe is employed by Web Application project because I want to customize Interop generation.

like image 849
Bahribayli Avatar asked Sep 06 '26 06:09

Bahribayli


1 Answers

There is most likely an error in your Delphi code. You can debug the COM library in Delphi like so:

enter image description here Choose run-> parameters...

enter image description here

(Never mind the fact that this says project28.exe; it works the same for Projectx.dll)

I commonly develop plugins for Excel using COM.
In that case my host application is Excel.exe.

When you've entered this info you'll be able to run the library.
When you do Delphi will start the host application and wait until it somehow invokes your library.
If you've set any breakpoints Delphi will pause the action and allow you to debug.

Because you know which functions you call in your C# code, it shouldn't be difficult to see where to set the first breakpoint.

Delphi will also break on any exceptions.

like image 107
Johan Avatar answered Sep 07 '26 20:09

Johan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!