Reputation: 7098
I am facing "chicken or the egg" dilemma.
Finally, after many hours of struggling with CIL, I have created an instance of class that was generated by using System.Reflection.Emit
& Activator.CreateInstance()
method. However, because class is dynamic, Visual Studio is not aware of the class, so I can't really code with it. How do I make it usable and accessible to other code ?
Clarification:
I have created a dynamic class that represents content of UI ListBox
. Users can go in, and change the content of ListBox
, generating new class. I need to make my dynamic class to be usable by rest of the application, that is not really aware of this new type/class.
Upvotes: 1
Views: 63
Reputation: 171246
You can't make it available statically. You need to use some kind of dynamic access. Or, make the class implement an interface and cast instances of that class to the respective interface type.
A very easy solution is to use dynamic
if member names are statically known.
Upvotes: 3