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

G

Guest

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.
 
F

Fabio Cannizzo

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
 

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