Create a DLL in C# to use in VB 6

  • Thread starter matt.b.williams
  • Start date
M

matt.b.williams

I am curious if the following is possible, and if so, if someone could
give me some guidance.

Is it possible to develop a DLL in C# and use it within a VB 6
application. I have seen other information regarding developing a
ActiveX/COM component within C# and using within VB 6, and from what I
saw, it seemed possible. Currently, I have developed only a simple dll
to test the code is as follows.

using System;
namespace SocketTransfer
{
public interface TransferFunctions
{
string GetVersion();
}

public class cTransfer: TransferFunctions
{
public string GetVersion()
{
return "Version 1.0.0"
}
}
}

Once I built this DLL, I registered it with regasm using the /tlb
command line parameter. Then, within VB 6, when I try to add a
reference to the DLL, it tells me that "Can't add a reference to the
specified dll". If I add a reference to the .TLB file that was created
I can create an object of the cTransfer class, but I can't see the
GetVersion function. Also, if I try to run the VB 6 application with
the .TLB file referenced, I get an Automation error saying that it
"Cannot create a file when that file already exists." It also
mentioned that it had something to do with the MSCOREE.DLL.

Is there any way to accomplish what I am trying to do above. If so, I
would appreciate it very much if someone could point me towards some
tutorials, examples, etc.

Thanks in advance for any assistance that may be provided.
 
M

Mattias Sjögren

Matt,
If I add a reference to the .TLB file that was created
I can create an object of the cTransfer class, but I can't see the
GetVersion function.

You may have to mark the types with the ComVisible(true) attribute.



Mattias
 

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