Question on Reflection

S

Srikumar Natarajan

I have a question on Reflections.

Basically, I have two visual studio solutions: SolA & SolB.

SolA has a console application project and a class library project. SolB has
some framework class libary projects. The console application proj in SolA
has references to many of the framework class library projects in SolB.

There is one particular project in SolB that has some code to load the
assembly of the class libabry project in SolA. I am using the following call
for loading the assembly.
Assembly asm = Assembly.Load("SolA.ClassLibProj");

I basically need to create an instance of a class present in the SolA
classLibProj using reflections. But, for some reason the line fails stating
an error that the file not found.

To summarize, the execution starts in SolA.ColsoleProj; Then a call happens
to SolB's framework project that inturn tries to load the SolA.ClassLibProj
through assembly.

Please let me know where I am going wrong.

Thanks,
Srikumar
 
N

Nicholas Paldino [.NET/C# MVP]

Srikumar,

The fact that the projects are in different solutions doesn't really
mean much. A solution is a logical construct, it doesn't correspond to any
physical output.

Why not just have a reference from the class library project in solution
B to the library in solution A? It sounds like you really have one set of
libraries which are being used by two executables (which is fine). Why not
have the executables exist in the same directory with the libraries, or
install the libraries in the GAC?
 
S

Srikumar Natarajan

Thanks for your help. I used Assembly.LoadFile instead and pointed the
location of the dll. It now works. Thanks again

Nicholas Paldino said:
Srikumar,

The fact that the projects are in different solutions doesn't really
mean much. A solution is a logical construct, it doesn't correspond to
any physical output.

Why not just have a reference from the class library project in
solution B to the library in solution A? It sounds like you really have
one set of libraries which are being used by two executables (which is
fine). Why not have the executables exist in the same directory with the
libraries, or install the libraries in the GAC?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Srikumar Natarajan said:
I have a question on Reflections.

Basically, I have two visual studio solutions: SolA & SolB.

SolA has a console application project and a class library project. SolB
has some framework class libary projects. The console application proj in
SolA has references to many of the framework class library projects in
SolB.

There is one particular project in SolB that has some code to load the
assembly of the class libabry project in SolA. I am using the following
call for loading the assembly.
Assembly asm = Assembly.Load("SolA.ClassLibProj");

I basically need to create an instance of a class present in the SolA
classLibProj using reflections. But, for some reason the line fails
stating an error that the file not found.

To summarize, the execution starts in SolA.ColsoleProj; Then a call
happens to SolB's framework project that inturn tries to load the
SolA.ClassLibProj through assembly.

Please let me know where I am going wrong.

Thanks,
Srikumar
 

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

Top