Creating instance of type withoguht reference to assembly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i know its possible to load an assembly and create instances of the types contained however is it possible to do this withough calling the assembly.createinstance method? but using the Activator class insted? so a reference to each assembly does not need to be maintained??
 
I don't understand all you're saying, but if you want to call a method
without instantiating the class to which the method belongs you delare the
method static.

Spike said:
i know its possible to load an assembly and create instances of the types
contained however is it possible to do this withough calling the
assembly.createinstance method? but using the Activator class insted? so a
reference to each assembly does not need to be maintained??
 
What do you mean by a "reference to each assembly"? You mean a
System.Reflection.Assembly variable reference? Because Activator loads one
of those internally anyways.

-mike
MVP
 
if u set a reference to an assembly in the project u can then use any types within that just like they were in the local project, is it possible to mimic this at runtime? as with the assembly.load u would need to make the destinction between loacal project types and types stored in each assembly as local ones could be created with activator while assembly ones would need the createinstance method of the reference to that indevidual assembly.
 
In C#, you can do this with Interfaces. Define an interface, and then
program against that. You only need to reference the interface assembly.
Then, at runtime, load up any assembly that has classes that implement the
interface, and instantiate from them. This will provide a strongly bound way
of handling things, and perf will be ok.

Or, go VB's way :) and have everything late bound. However, the perf of a
method call is going to be something like 100 or 1000 times worse.

-mike
MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top