VB6 and C# interoperation
-
-
hey guys, what`s the fastest way to use my C# methods within my VB6 app? I`ve done it before, but i can`t remember where exactly i found the article about how to accomplish it. do you know any reference about the subject? thanks in advance cheers
-
hey guys, what`s the fastest way to use my C# methods within my VB6 app? I`ve done it before, but i can`t remember where exactly i found the article about how to accomplish it. do you know any reference about the subject? thanks in advance cheers
with VB6, you'll need to compile your C# as a COM object, or a completely independent app and use standard windows interprocess communications to talk between then. It's only easy if you're using VB.net since it uses the same runtime.
-- Rules of thumb should not be taken for the whole hand.
-
hey guys, what`s the fastest way to use my C# methods within my VB6 app? I`ve done it before, but i can`t remember where exactly i found the article about how to accomplish it. do you know any reference about the subject? thanks in advance cheers
Like Dan said, you have to decorate your C# component with the proper COM appointments in order to use it in VB6. COM is the only interface you have to enable your component to work with VB6. C#, or and managed code library for that matter, doesn't support the necessary exports to use simple Declare statements in your VB6 code. Keep in mind, that when you use a .NET component in your VB6 code, you're bringing with it the entire weight of the .NET CLR. Be prepared to see your memory counters jump up considerably. You can learn a bit more about this process in this article[^] on MSDN. The .NET code is in VB.NET, but is easily translatable to C#. There's more in the next article[^].
Dave Kreskowiak Microsoft MVP - Visual Basic