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

Problems importing C# DLL into VB6.0 project (urgent)

P: n/a
em
Hi all,

I'm getting some problems importing a DLL that I made in C# within VB6.0.
The C# is quite easy, just for trying:

namespace TestDll
{

public class Class1

{
public int SumNumbers(int numn1, int num2)
{
int sum = num1 + num2;
return sum;
}
}
}

I developd the C# project as a Project Library, so the DLL is correctrly
created.
I don't have any problem if I use the DLL within a C# project.
Whereas, if I use the DLL in a VB6.0 project it doesn't work. The class is
correctly imported and I can create an object of that class, but it is not
possible to access at the method (SumNumbers).
In the project properties I setted the 'Register for COM Interop' as true,
but I tried both, true and false, and it doesn't work.

Any suggestions?

Thank you very much in advance.
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You need to define carefully your interfaces if you want your COM object to
work. Not an easy answer, you have to study about COM interop.

There is lot of stuff on the MSDN.

In WROX web site, in the section related to the book "Professional C# 3rd
edition", there is same sample code that you can download. Look at the code
rel;ated to Chapter 28 (actually, I think having the book would help).

Alternatively, do a search on google for "Interop COM C#"

Cheers,
Fabio
"em" <em@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
Hi all,

I'm getting some problems importing a DLL that I made in C# within VB6.0.
The C# is quite easy, just for trying:

namespace TestDll
{

public class Class1

{
public int SumNumbers(int numn1, int num2)
{
int sum = num1 + num2;
return sum;
}
}
}

I developd the C# project as a Project Library, so the DLL is correctrly
created.
I don't have any problem if I use the DLL within a C# project.
Whereas, if I use the DLL in a VB6.0 project it doesn't work. The class is
correctly imported and I can create an object of that class, but it is not
possible to access at the method (SumNumbers).
In the project properties I setted the 'Register for COM Interop' as true,
but I tried both, true and false, and it doesn't work.

Any suggestions?

Thank you very much in advance.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.