MegaByte
MegaByte

Reputation: 6845

Compile C# code into a DLL and access that C# DLL from VB6.0 declaring it as an API call

In my VB6.0 days I used tons of windows API. So I got the idea that all the API methods that I declared are pretty much procedure based - or it has a procedure based entry point.

My question:

I have written some code in C# which I need to access from VB6.0. Is it possible to compile my C# code into a DLL and access that C# DLL from VB6.0 declaring it as an API call? If so, how is this done ?

(I have already tried making my C# DLL COM compliant, and it worked - but I would like to try the above mentioned approach anyway)

Upvotes: 0

Views: 269

Answers (2)

Ant
Ant

Reputation: 5225

If you're happy to get your hands (very) dirty, you can do what you want by using MSIL. Have a look at this CodeProject project for a walkthrough.

Upvotes: 0

itowlson
itowlson

Reputation: 74832

No, you can't expose the entry points to your C# DLL as Win32-style APIs. If you really, really need to create procedural entry points for a .NET library, probably the best thing to do is create a mixed-mode wrapper library using C++/CLI. But this seems like hard work: exposing your C# classes as COM objects is likely to be a lot less effort and much easier to maintain.

Upvotes: 4

Related Questions