views:

54

answers:

1

When doing dynamic compiling of C# source code, if we happen to try to execute a compiled target DLL (for example tmp901.tmp.dll) that has a missing reference, for example:

*InnerException: Could not load file or assembly '_O2_Scanner_MsCatNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.*

There seems to be an issue where, for the duration of that process, that assembly will never be resolved, even if the file is copied to the location where the target assembly (tmp901.tmp.dll) is being executed from. There seems to be a caching issue going on that prevents the recheck for the dll existence.

The current solution is to restart the host .NET app which is not really practical.

A: 

Once the assembly load fails, I believe you can still load the assembly manually using Assembly.Load or Assembly.LoadFile. This should allow you to force the assembly to load, even if it's failed once.

Reed Copsey