Hi,
I am new to c# and not sure how to do the following.
I have to namespaces. Namespace2 is compiled at runtime and always has a different name. The properties and methods are however known.
From namespace1 I want to be able to access instances of a class in namespace2.
To get a reference to this class I tried something like:
Then I have a method in class1 in namespace1 with a reference to the created classType that looks like
This returns the error:
"classType is a `field' but a `type' was expected"
Anyone knows what goes wrong or how to do this kind of thing?
Thanks!
I am new to c# and not sure how to do the following.
I have to namespaces. Namespace2 is compiled at runtime and always has a different name. The properties and methods are however known.
From namespace1 I want to be able to access instances of a class in namespace2.
To get a reference to this class I tried something like:
Code:
Type classType;
...
Assembly a = Assembly.Load("namespace2");
classType = a.GetType("namespace2.ClassName");
Then I have a method in class1 in namespace1 with a reference to the created classType that looks like
Code:
public void TestClass(classType testclass){
...
}
This returns the error:
"classType is a `field' but a `type' was expected"
Anyone knows what goes wrong or how to do this kind of thing?
Thanks!