-
November 15th, 2005, 01:00 PM
#1
Use .net dll in VB6?
I want use a .net dll in vb6. I have selected "Register for COM Interop" in VS.net proyect. I have registered dll with resgam. I have generated .tlb file. I have add in references tlb file. But when I run it tak error "File or asembly name xxxx , or one of its components, was not found".
Before register with resgam the error was "ActiveX component can't create object".
Do you know how use .net dlls in vb6?
Thanks
_______________
Hip Hop
Foro heavy
-
November 16th, 2005, 02:40 AM
#2
Re: Use .net dll in VB6?
Take a look at this tutorial http://msdn.microsoft.com/library/de...ertutorial.asp. This might help a bit in understanding how COM interop actually works. This is in C# but should be helpful in this case.
-
November 16th, 2005, 04:39 AM
#3
Re: Use .net dll in VB6?
Thanks I have solve it.
But now I have another problem, when I write "object." it don't shome the public methods of the class (after write dot).
If I write method it runs ok, but can I show the methods of the class when I write dot after de object?
Thanksss
-
November 16th, 2005, 05:05 AM
#4
Re: Use .net dll in VB6?
Originally Posted by wakeup
Thanks I have solve it.
But now I have another problem, when I write "object." it don't shome the public methods of the class (after write dot).
If I write method it runs ok, but can I show the methods of the class when I write dot after de object?
Thanksss
This is because you are use Late Binding. Late Binding means that compiler will only come to know about the actual ActiveX at run-time. This is the reason why inteli-sense of VB doesn't work when you declare objects using generic object class.
-
November 16th, 2005, 06:02 AM
#5
Re: Use .net dll in VB6?
How can I solve it?
thanks
-
November 16th, 2005, 06:51 AM
#6
Re: Use .net dll in VB6?
Originally Posted by wakeup
How can I solve it?
thanks
You will have to use Early-Binding. I would declare my object like this to
Code:
Dim myObject As New NetObjectClass
Where NetObjectClass is the names of the Class you created in .NET.
-
November 16th, 2005, 06:59 AM
#7
Re: Use .net dll in VB6?
I have tried it but inteli-sense don't work.
PD: Sorry, my english is bad, i'm spanish.
-
November 16th, 2005, 07:07 AM
#8
Re: Use .net dll in VB6?
Originally Posted by wakeup
I have tried it but inteli-sense don't work.
This means that the Class you developed in VB.NET does not have a public interface. You should define a public interface for your class. This way VB 6.0 intelli-sense will be able to show all the public methods/properties of your VB.NET class
Originally Posted by wakeup
PD: Sorry, my english is bad, i'm spanish.
I am also not from an English speaking country. So no worries
-
November 16th, 2005, 07:41 AM
#9
Re: Use .net dll in VB6?
This is the code of the test-dll. The class and the test method are public.
Code:
public class ClasePrueba
{
public ClasePrueba()
{
}
public int prueba(int a, int b)
{
return a * b +5;
}
}
This is you have told me?
thankss
-
November 16th, 2005, 07:58 AM
#10
Re: Use .net dll in VB6?
I don't see an INterface defined for the Class. I have modified your test class and included an Interface that contains the definition of the public members of the class. Take a look at the code, copy it and Compile the assembly again (don't forget to check "Register for COM Interop in the project properties)
Code:
//define a public interface which will contain all the public members of the class
//the methods that are not public should nto be written in the interface
public interface iClasePrueba{
public int prueba(int a, int b);
public string Hello(string sMessage);
}
//implement the interface defined above
public class ClasePrueba : iClasePrueba
{
//constructor
public ClasePrueba()
{
}
publicint prueba(int a, int b)
{
return a * b +5;
}
//Another property just to show how interface works
publicstring Hello(string sMessage)
{
return "Hello " + sMessage + " from witrhin .NET";
}
}
If you have written your class in C#, then you should have posted this thread inn C#.
-
November 16th, 2005, 10:29 AM
#11
Re: Use .net dll in VB6?
I have tried it, and intellinense don't appear.
Then I have searched in google and I have seen this.
http://www.vb-helper.com/howto_vb6_use_net_dll.html
I have write
Code:
[ClassInterface(ClassInterfaceType.AutoDual)]
Before class definition and intelliense is ok.
Do you know what is exactly this ?
Code:
[ClassInterface(ClassInterfaceType.AutoDual)]
Thanks
-
November 17th, 2005, 02:26 AM
#12
Re: Use .net dll in VB6?
Using ClassInterFace.AutoDual will publish the Type information for the Class, that needs to be exposed to COM clients, to a Type Library.
ClassInterFace indicates the type of Class Interface that needs to be generated for class that is exposed to the COM.
AutoDial should not be used because of versioning issues.
Lookup in MSDN for more details on this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|