.NET Framework - Calling C#Dll from Vb6

Asked By DaveP on 26-Sep-07 02:40 PM
Hi all...im looking for example of
calling a method or class in c# dll from vb6

i have a Class writen in c#
Ii want to call it from vb6 (ie Not a c# exe, DLL)

tia
DaveP




Nicholas Paldino [.NET/C# MVP] replied on 26-Sep-07 02:52 PM
Dave,

I would look at the section of the .NET documentation titled "Exposing
.NET Framework Components to COM", located at:

http://msdn2.microsoft.com/en-us/library/zsfww439(VS.71).aspx


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
Michael Starberg replied on 26-Sep-07 03:26 PM
Well, this is pretty easy to do,
Just expose your C# assembly as COM,
and it will work just fine in your VB6 code.

[singing]
But there is a part of me
that would like to tell
and thereby lie
that it is impossible..
Just to have you re-write
your entire application
- Just to rid the world of VB6 =)

But, I am happy too see you are moving in the right direction.


Visual Basic Sucks So Hard It Bends Light
- Michael Starberg
DaveP replied on 26-Sep-07 03:42 PM
I agree, i would never write vbcode and i still hate it...
this is legacy code
For the time being i cannot rewrite yet
But im trying to slowly a Part at a time
DaveP
Michael Starberg replied on 26-Sep-07 04:46 PM
Well, I'll pray for you.
Anyone doing VB6 without wanting to,
deserves to have a candle lit for him/her.

But you will find that it is easy to get an
assembly to work in the COM-world.
Just a checkbox if I remember correctly.

In the meantime, you can always laugh with Verity Stobs:
- Thirteen Ways To Loath VB:

http://www.ddj.com/windows/184403996

Candle Lit
- Michael Starberg
DaveP replied on 26-Sep-07 05:37 PM
i have to take prozac everytime i open a vb project
Cor Ligthert[MVP] replied on 27-Sep-07 12:13 AM
Michael,



Any reason, just try the VBNet version from what is in C# the switch, maybe
that is the first start in loving VBNet.

Cor
Michael Starberg replied on 27-Sep-07 05:08 PM
I usually settle for coffee.

But when I maintain VB6 code,
I am always thinking that I need LSD
to even begin to understand what the
original coder was trying to do.
And what all the patches ontop of that
was trying to solve in panic.

I wonder if there is a support group for this?

-  eh, eh, I've been like a VB6 maintainer for..
.. a long time now...
.. sometimes I get VB6, but sometimes they only give me VBA
.. for office-applications..
.. also, I had to do vbscript in asp, just to get a new hit
.. been doing that...
.. for like 6 years now. I'm shaking and can't sleep
.. because of all the nightmares.
.. my name is Michael

- HELLO MICHAEL, we are here for you...

Luckely for me, C# came to the rescue.
Also, I have still a pretty complex
Delphi7 application that I work on, on my free time.

If not, I'd been in that support group,
becoming Tyler Durden making viruses targeting COM. :)

Cato said in the Roman Senate
that Carthago should be destroyed.
That is a missspelling by the dude taking notes,
or maybe the Cato was a wee drunk and slurled it out
but, he ment that COM should be be destroyed.

See, that is what I call an insight.

But Bill don't take orders from Cato, now does he. =)

- Michael Starberg