Assembly.LoadFrom strange behaviour

J

Juan

Hello

I'm Developing for PDA and usingAssembly.LoadFrom("") method, but obtaining
a strange behavoiur.

If i use an old DLL I compiled long time ago, the method correctly loads
the assembly dinamically, but If i use now compiled DLL, instead of return
the DLLs assembly it returns my EXE assembly, without giving any error.

The Path and DLL localization is correct.

Anybody can help me?

thanks
Juan
 
D

Daniel Moth

Are the assemblies in the gac? Has the dll and exe got the same name? In all
cases, post some code along with a description of your setup so we can
replicate it.

Cheers
Daniel
 
J

Juan

The assemblie is in the same directory as the exe, and it has the same name.

I don't have any setup proyect, just implement it trought visual studio or
copy the dll manually.

Thanks
 
J

Juan

I've discovered that if the dll was compilated yesterday, it works fine, but
if it have been compilated today, Assembly.LoadFrom takes the exe instead of
the dll.
I don't know why of this strange behaviour.

Thanks
 
J

j.edwards

I've had similar issues too. Not certain that this will work, but I think
it's related to the version numbers incrementing, and .net seems to be
pretty "precise".

Something you could try is in your AssemblyInfo.vb there is a line near the
bottom:

<Assembly: AssemblyVersion("1.0.*")>

Version numbers are e.g. 1.0.10.50. The "*" tells visual studio to increment
the last two numbers as you build etc. So change the line to:

<Assembly: AssemblyVersion("1.0.0.0")>

This will keep the version number the same. You may need to do this just on
the dll, or on your exe as well - give it a go and see if it helps.
Alternatively, if you build both the exe and dll at the same time you should
never get any problems - i.e. have them both in the same solution and both
set to build.
 

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