By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,338 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,338 IT Pros & Developers. It's quick & easy.

Create a DLL in C# to use in VB 6

P: n/a
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.

Apr 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Apr 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.