471,314 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,314 software developers and data experts.

Problem with assembly loaded at runtime

When I load an assembly at runtime, that is to say, a plugin DLL through
Assembly.Load, an old version of the assembly is loaded.
If I recompile the DLL and then copy the result to where the assembly is
loaded by the main app, anyway, the old assembly is used. From where ?, I
don't know. I don't have an error here. Checked several times, because if I
delete the assembly, at runtime it is not detected by the
Directory.GetFiles() method. It is as if the updated assembly is not taken
into account and an old version is always reloaded.

How to solve that ? It is the same problem if I shutdown and restart VS2003
or the computer.
Thanks in Advance
Luis Arvayo
Jan 20 '06 #1
5 1750
Luis Arvayo wrote:
When I load an assembly at runtime, that is to say, a plugin DLL
through Assembly.Load, an old version of the assembly is loaded.
If I recompile the DLL and then copy the result to where the assembly
is loaded by the main app, anyway, the old assembly is used. From
where ?, I don't know. I don't have an error here. Checked several
times, because if I delete the assembly, at runtime it is not
detected by the Directory.GetFiles() method. It is as if the updated
assembly is not taken into account and an old version is always
reloaded.

How to solve that ? It is the same problem if I shutdown and restart
VS2003 or the computer.


Check if the old assembly is in the GAC:
vsvars32.bat
gacutil /l

you should also check the download cache:
gacutil /ldl

and if it's there, clear it:
gacutil /cdl

If you know the filename, it's often better to use LoadFrom.

Frans

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Jan 20 '06 #2
Frans Bouma [C# MVP] wrote:
Luis Arvayo wrote:

When I load an assembly at runtime, that is to say, a plugin DLL
through Assembly.Load, an old version of the assembly is loaded.
If I recompile the DLL and then copy the result to where the assembly
is loaded by the main app, anyway, the old assembly is used. From
where ?, I don't know. I don't have an error here. Checked several
times, because if I delete the assembly, at runtime it is not
detected by the Directory.GetFiles() method. It is as if the updated
assembly is not taken into account and an old version is always
reloaded.

How to solve that ? It is the same problem if I shutdown and restart
VS2003 or the computer.

Check if the old assembly is in the GAC:
vsvars32.bat
gacutil /l

you should also check the download cache:
gacutil /ldl

and if it's there, clear it:
gacutil /cdl

If you know the filename, it's often better to use LoadFrom.

Frans

I once had a problem when a plugin got into the download cache. I found
it by opening a cmd shell and typing:

dir "%USERPROFILE%\..\PlugIn.dll" /B /S
Is you DLL listed at a place where it shouln't be?

HTH,
ANdy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net
Jan 20 '06 #3
The loader uses the following logic to find your assembly (by default,
you can change this somewhat)

GAC (If the assembly has a strong name)
CODEBASE
Probing (searching the APPBASE directory (where the configuration file
resides) and any subdirectories that are specified in apps configuration
assemblyBinding element) ... basically, it first looks for a library
with the appropriate name in the APPBASE directory, if it cannot find
it, it looks for a directory with the name of the assembly, and looks in
that directory for the assembly (library.) If that fails, it goes back
and uses the .exe extension vs. the .dll extension for the previous two
steps. If still not found it starts looking down the paths specified in
the assemblyBinding element.

An exception to the steps above is that if your load request contains a
cultural identifier, the loader will try to include that in the path as
well.
After all that ... are you running a copy of this from an ASP.NET
session and just compiling the library? In that case, you library could
be in the shadow directory?


Luis Arvayo wrote:
When I load an assembly at runtime, that is to say, a plugin DLL through
Assembly.Load, an old version of the assembly is loaded.
If I recompile the DLL and then copy the result to where the assembly is
loaded by the main app, anyway, the old assembly is used. From where ?, I
don't know. I don't have an error here. Checked several times, because if I
delete the assembly, at runtime it is not detected by the
Directory.GetFiles() method. It is as if the updated assembly is not taken
into account and an old version is always reloaded.

How to solve that ? It is the same problem if I shutdown and restart VS2003
or the computer.
Thanks in Advance
Luis Arvayo

Jan 20 '06 #4
> Is you DLL listed at a place where it shouln't be?
Yes, thank you this tip solved the problem.

"Andreas Mueller" <me@privacy.net> escribió en el mensaje
news:43*************@individual.net...
Frans Bouma [C# MVP] wrote:
Luis Arvayo wrote:

When I load an assembly at runtime, that is to say, a plugin DLL
through Assembly.Load, an old version of the assembly is loaded.
If I recompile the DLL and then copy the result to where the assembly
is loaded by the main app, anyway, the old assembly is used. From
where ?, I don't know. I don't have an error here. Checked several
times, because if I delete the assembly, at runtime it is not
detected by the Directory.GetFiles() method. It is as if the updated
assembly is not taken into account and an old version is always
reloaded.

How to solve that ? It is the same problem if I shutdown and restart
VS2003 or the computer.

Check if the old assembly is in the GAC:
vsvars32.bat
gacutil /l

you should also check the download cache:
gacutil /ldl

and if it's there, clear it:
gacutil /cdl

If you know the filename, it's often better to use LoadFrom.

Frans

I once had a problem when a plugin got into the download cache. I found it
by opening a cmd shell and typing:

dir "%USERPROFILE%\..\PlugIn.dll" /B /S
Is you DLL listed at a place where it shouln't be?

HTH,
ANdy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net

Jan 21 '06 #5

Thanks for the clear explain. It take me directly to the fact that the DLL
was located in a wrong place.
"John Murray" <jm*****@pluck.com> escribió en el mensaje
news:Oh**************@TK2MSFTNGP09.phx.gbl...
The loader uses the following logic to find your assembly (by default, you
can change this somewhat)

GAC (If the assembly has a strong name)
CODEBASE
Probing (searching the APPBASE directory (where the configuration file
resides) and any subdirectories that are specified in apps configuration
assemblyBinding element) ... basically, it first looks for a library with
the appropriate name in the APPBASE directory, if it cannot find it, it
looks for a directory with the name of the assembly, and looks in that
directory for the assembly (library.) If that fails, it goes back and
uses the .exe extension vs. the .dll extension for the previous two steps.
If still not found it starts looking down the paths specified in the
assemblyBinding element.

An exception to the steps above is that if your load request contains a
cultural identifier, the loader will try to include that in the path as
well.
After all that ... are you running a copy of this from an ASP.NET session
and just compiling the library? In that case, you library could be in the
shadow directory?


Luis Arvayo wrote:
When I load an assembly at runtime, that is to say, a plugin DLL through
Assembly.Load, an old version of the assembly is loaded.
If I recompile the DLL and then copy the result to where the assembly is
loaded by the main app, anyway, the old assembly is used. From where ?, I
don't know. I don't have an error here. Checked several times, because
if I delete the assembly, at runtime it is not detected by the
Directory.GetFiles() method. It is as if the updated assembly is not
taken into account and an old version is always reloaded.

How to solve that ? It is the same problem if I shutdown and restart
VS2003 or the computer.
Thanks in Advance
Luis Arvayo

Jan 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Arnaud Debaene | last post: by
28 posts views Thread by Jon Davis | last post: by
1 post views Thread by Zachary Hartnett | last post: by
4 posts views Thread by Edward Diener | last post: by
12 posts views Thread by Steven Berkovitz | last post: by
19 posts views Thread by Larry Smith | last post: by
4 posts views Thread by =?Utf-8?B?SmFu?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.