Accessing VB component property methods from C# application  
Author Message
Hemant Hindlekar





PostPosted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application Top

Hello

Can someone help me for the below proble,

I am working on a task of converting one vb6 application in .Net.

Current vb6 application is using one vb dll provided by third party. I have written a code in C# and added the third party dll (developed in vb6) in the reference. The strange problem I am facing is that I am able to access all the properties of vb6 dll but not the methods of the property.One thing I do not know is whether the property datatype is collection or any other datatype.

For example :

TestClient.Client objClient = new TestClient.Client();

I am able access the "GenericBO' property of the objClient but not the "Item" method of the "GenericBO' property.

In current VB6 the same property method is accessed as below

objClient.GenericBO.Item("Administrator").value = "test"

Due to above problem tried the same thing in VB.NET application and found that it works.

Any reason why it is not working in C#.




Visual Basic14  
 
 
danych





PostPosted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application Top

HI,

Just add the reference "Microsoft Visual Basic .NET Runtime" to your project.

you needs to import "using Microsoft.VisualBasic;"

then try to access the control's methods that you want.

hope that answers ur questions



 
 
Hemant Hindlekar





PostPosted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application Top

Hi

Thanks for the reply.

I tried as per your suggestion but I get the error at the time of compilation itself because at the time of compilation it tries to search for the method. The error message is "Object does not contain a defination for item".

Genericbo object contains the method Item() which I am able to see in VB.Net , hence do not get this error VB.Net.

In C# I am unable to see this method so i get the error at the time of compilation. If I do get the solution then I might have to go for VB.Net. Lets see.



 
 
CommonGenius.com





PostPosted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application Top

The Item() method in VB is expressed as an indexer in C#. Try objClient.GenericBO["Administrator"].value = "test"