Reputation: 186
This :
public class Something
{
public string lala = "";
public class Lala
{
//...
}
}
is legal C# now I compile it etc and drop the dll in a new Vb.Net project : how do I access member lala
from VB.Net, if I try I get the error "'lala' is ambiguous because multiple kinds of members with this name exist in class Something".
Upvotes: 0
Views: 178
Reputation: 6542
Unfortunately, you're probably going to have to resort to reflection to access this dll. Once you get your System.Type instance for the 'Something' class (using the 'GetType' instance method of the System.Reflection.Assembly type), you will use the type instance's 'GetField' method to access the 'lala' field and the type instance's 'GetNestedType' method to access the 'Lala' nested type.
Imports System.Reflection
...
Dim assembly As Assembly = Assembly.Load(...)
Dim outerType As Type = assembly.GetType("Something")
Dim field As FieldInfo = outerType.GetField("lala")
Dim nestedType As Type = outerType.NestedType("Lala")
You would then use field.SetValue(..) and field.GetValue(..) to access the 'lala' field.
Upvotes: 1
Reputation:
First: Add the reference to your project.
Browse to your Something_Lala DLL file and add it.
Next, you need to import that into your file, initialize it, and then use it.
The example code looks bad, but that was all you gave the SO community to work with.
Upvotes: 1