Calling a "Public Shared" VB.NET function from VB6?

G

Guest

(I previously posted this problem on vb.general.discussion but I've been told
that this question is more related to VB.NET than VB6 and so that I should
post that here.)


I'm trying to call a "Public Shared" function in a dll built in VB.NET from a
VB6 program.

Whenever I try, I get an error saying that the function doesnt exist. I had
doubts that the "Shared" in the VB.NET dll could be the problem. I tried to
recompile the dll without the "Shared" and I can now call it from VB6 without
problem. It's as if the "Shared" made it so VB6 could no longer communicate
with the DLL, as if the function wasnt existing at all from the VB6 point of
view.


Is there a way to call a "Shared" VB.NET function from VB6?


(Right now I have two workarounds that I dont really like:
1- Remove the "Shared" from the function
2- Make an intermediate VB.NET dll whose sole purpose is to call the
"Shared" function of the other VB.NET dll)
 
R

Rick Mogstad

I dont think you will be able to do it because VB6 is calling the VB.NET dll
via COM (via interop) and AFAIK there is no such thing as "static" methods
in VB6/COM, so it likely just doesnt know how to call anything that is not
related to a particular instance of the class.

I hope that makes sense, I have had little sleep.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top