i have written some code that determines at runtime which objects it should instantiate. I am also able to add new classes at runtime by adding new dlls to the projects binary output directory.
public static AbstractBase<T> Create<T>() where T : class
{
string implementationTypeName = ConfigurationManager.AppSettings["Class"];
string assemblyName = ConfigurationManager.AppSettings["Assembly"];
string typeParmaterName = typeof(T).ToString();
string typeName = string.Format("{0}`1[[{1}]], {2}", implementationTypeName, typeParmaterName, assemblyName);
Type type = Type.GetType(typeName, true);
// Singleton used in implementation
var instance = type.GetProperty("Instance").GetValue(null, null)
return new Base<T>((IImplementation<T>)instance);
}
*** Assembly Binder Log Entry (31.05.2011 @ 13:16:15) ***
The operation failed.
Bind result: hr = 0x80070002. Das System kann die angegebene Datei nicht finden.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Programme\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2010\nCrunch.TaskRunner40.x86.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = GROUP\r892107
LOG: DisplayName = RWEST.Trading.WeatherDashboard.CacheManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///B:/Temp/4172/62/bin/debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = nCrunch.TestRunner_141f3976b0d7453083b0e2bf2bf34e3e
Calling assembly : Base.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///B:/Temp/4172/62/bin/debug/Base.DLL.
LOG: Attempting download of new URL file:///B:/Temp/4172/62/bin/debug/Base/Base.DLL.
LOG: Attempting download of new URL file:///B:/Temp/4172/62/bin/debug/Base.EXE.
LOG: Attempting download of new URL file:///B:/Temp/4172/62/bin/debug/Base/Base.EXE.
LOG: All probing URLs attempted and failed.
To make my unit test go green i have to copy the implementation DLL to the tests binary output directory.
Unfortunately NCrunch only checks its temp paths for the specified assembly.