Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling a C# DLL from VB6

45 views
Skip to first unread message

Stu

unread,
Feb 17, 2009, 3:56:16 PM2/17/09
to
I wrote a C# DLL with (I believe) all the necessary COM interop stuff,
registered it and created a tlb file with regasm, strongly named it
and registered it in the GAC. The entire purpose of the DLL is
basically a wrapper which creates and exports a chart (I'm using
Dundas Charts). I can run it just fine from a C# program and it does
exactly what it's meant to do, however when I reference it in VB6 and
try calling the wrapped Draw function it gives me a file not found on
the Dundas DLL. I've even wrapped the entire Draw function in a try/
catch, but this error is still making it back to the VB program. The
rest of the interop is working fine, I can get/set properties and call
other functions, but when I call the function which in turn creates a
Dundas Chart object and exports it, I get this error:

Could not load file or assembly 'DundasWinChart' (etc etc) or one of
its dependencies. The system cannot find the file specified.

Even though I don't think any of these things are necessary, I'm
grasping at straws so I tried placing the file in the directory of the
VB program I'm calling it from, also put it in the VB6 directory,
tried doing a regasm on it, tried adding it to the GAC. None of these
had any effect and I'm still getting the same error. Is there
something I'm missing here? I've been googling for the past several
hours trying to figure out why this won't work. Any help is much
appreciated.

Eusebiu

unread,
Feb 17, 2009, 5:15:01 PM2/17/09
to
Hello...
It looks like there's a problem inside the Draw function...
I think it would get an answer using this forum:
http://support.dundas.com/forum/

Hope it helps...

TDC

unread,
Feb 18, 2009, 8:17:08 AM2/18/09
to
Is the Draw function the 1st method invocation on your C# dll, or is
it just the 1st that utilizes the Chart component?

Also, I've found running ProcessMon (or FileMon/RegMon) to be helpful
with COM interop issues, as you can see what file or registry
locations the app hits as it tries to load your component.

Stu

unread,
Feb 18, 2009, 10:05:19 AM2/18/09
to

Eusebiu - As I said, the DLL works perfectly when called from a .NET
application. It's only when being called from VB6 that it fails, so I
don't think it's a problem with the Draw function.

TDC - In the testing I've been doing it is the first method to be
called, though in practice there will be other methods called first.
But in both the .NET test program and the VB6 test program I'm calling
it in the same fashion, just instantiating the class and then calling
its Draw function. I'll look into ProcessMon to see if that sheds any
light.

Thanks.

Stu

unread,
Feb 18, 2009, 11:09:59 AM2/18/09
to


One thing I thought of, is it possible that the Dundas DLL is able to
recognize that the call originated from VB6 and is blocking itself
from running based on licensing or something like that? I think
that's a long shot, but again I'm grasping at straws at this point.

Ben Voigt [C++ MVP]

unread,
Feb 18, 2009, 1:32:43 PM2/18/09
to
Stu wrote:
> I wrote a C# DLL with (I believe) all the necessary COM interop stuff,
> registered it and created a tlb file with regasm, strongly named it
> and registered it in the GAC. The entire purpose of the DLL is
> basically a wrapper which creates and exports a chart (I'm using
> Dundas Charts). I can run it just fine from a C# program and it does
> exactly what it's meant to do, however when I reference it in VB6 and
> try calling the wrapped Draw function it gives me a file not found on
> the Dundas DLL. I've even wrapped the entire Draw function in a try/
> catch, but this error is still making it back to the VB program. The
> rest of the interop is working fine, I can get/set properties and call
> other functions, but when I call the function which in turn creates a
> Dundas Chart object and exports it, I get this error:
>
> Could not load file or assembly 'DundasWinChart' (etc etc) or one of
> its dependencies. The system cannot find the file specified.
>
> Even though I don't think any of these things are necessary, I'm
> grasping at straws so I tried placing the file in the directory of the
> VB program I'm calling it from, also put it in the VB6 directory,
> tried doing a regasm on it, tried adding it to the GAC. None of these

Which file? The error you are getting could be inability to find a DLL
needed by a DLL needed by a DLL needed by your DLL. That's the "or one of
its dependencies".

Stu

unread,
Feb 18, 2009, 1:55:45 PM2/18/09
to


Yeah I understand that, but why would it only not be able to find it
when running from VB6? I can reference my compiled wrapper DLL from a
C# application and it runs perfectly. Is there any way for me to tell
which file it thinks is missing?

Stu

unread,
Feb 18, 2009, 3:24:27 PM2/18/09
to

So bizarre...... I have no idea what I changed, but this is now
working. Thanks for the help, if I figure out what the problem was
I'll post the solution in case anyone else runs into a similar issue.

0 new messages