Reputation: 3177
I have 2 projects, in one project I have one form and class with different information, this information is acquiring only during runtime, now in another project I have another form, that will use the object of the first class to get the information and to put it inside form.
Basically I did some research and tried using Reflection for that, but all of the examples I found didn't work properly (actually didn't work at all).
Assembly a = Assembly.LoadFile("Server.GUI.LocalGUI.dll");
object o = a.CreateInstance("ServerManager");
Type t = o.GetType();
this is the code that I tried, not sure if it's correct...
I am using .net 2.0
Is anyone have working example of how to use data of one object in another dll on the runtime?
Upvotes: 0
Views: 1894
Reputation: 11727
I have 2 projects : MyForm1
and MyForm2
. Take reference of project MyForm1
in MyForm2
. Fill MyForm1
. Create a instance of the MyForm1
in MyForm2
and access the method and its value.
Or create another Library
project. Expose a static variable in it. Take reference of this library in both the Forms projects. Assign some value from MyForm1
and access the same property in MyForm2
.
But if you really want your code to be a managed code, try learning and implementing MVP. It may give you a new way to look at solutions for your problems.
You can even create both forms in same project. Process the data in a separate library.
Upvotes: 1
Reputation: 11287
if that is want you want to do - the you could do it like this:
Assembly a = Assembly.LoadFile("Server.GUI.LocalGUI.dll");
dynamic o = a.CreateInstance("ServerManager");
o.Method();
But i don't recommend this, unless you absolutly have to. Using the dynamic
keyword can be at shortcut - but sometimes a shortcut to a place you don't want to go..
Upvotes: 0