web analytics
Calling unmanaged DLL functions from C# Options
codeling
Posted: Thursday, September 14, 2017 2:29:49 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 892
Points: 3738

If all you have is that COM DLL, you can't generate a type library. A type library describes the COM interfaces implemented. But an unmanaged COM DLL merely needs to expose DllGetClassObject. This only gets you an IClassFactory, which lets you create new objects if you kown the correct type up front.

Sponsor
Posted: Thursday, September 14, 2017 2:29:49 PM
codeling
Posted: Thursday, September 14, 2017 2:32:43 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 892
Points: 3738

To extract type libraries from managed DLLs (e.g., the ones built using C#), Visual Studio includes the tool named Tlbexp.exe to generates a type library that describes the types defined in a common language runtime assembly.

codeling
Posted: Thursday, September 14, 2017 2:39:01 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 892
Points: 3738

When you specify the /tlb option with Regasm.exe (Assembly Registration Tool), Regasm.exe generates and registers a type library describing the types found in the assembly. Regasm.exe places the generated type libraries in the current working directory or the directory specified for the output file. Generating a type library for an assembly that references other assemblies may cause several type libraries to be generated at once. You can use the type library to provide type information to development tools like Visual Studio. You should not use the /tlb option if the assembly you are registering was produced by the Type Library Importer (Tlbimp.exe). You cannot export a type library from an assembly that was imported from a type library. Using the /tlb option has the same effect as using the Type Library Exporter (Tlbexp.exe) and Regasm.exe, with the exception that Tlbexp.exe does not register the type library it produces. If you use the /tlb option to registered a type library, you can use /tlb option with the /unregister option to unregistered the type library. Using the two options together will unregister the type library and interface entries, which can clean the registry considerably.

After registering an assembly using Regasm.exe, you can install it in the global assembly cache so that it can be activated from any COM client. If the assembly is only going to be activated by a single application, you can place it in that application's directory.

Users browsing this topic
Guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


© 2017 Digcode.com. All rights reserved.