I have the following class located in Assembly A. The assembly has a reference to StructureMap 2.6.1.
public static class Bootstrapper
{
public static void Bootstrap(string databaseName)
{
StructureMapBootstrapper.Bootstrap(databaseName);
}
}
I'm referencing Assembly A in a completely different Assembly (B) and I"m getting the following runtime error when this line is called:
Bootstrapper.Bootstrap(db);
The runtime error is:
FileNotFoundException: Could not load file or assembly 'StructureMap, Version=2.6.1.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223' or one of its dependencies. The system cannot find the file specified.
I'm constantly having to copy StructureMap.dll to the bin directory of Assembly B. This is incredibly annoying. Any suggestions on how to resolve this? Does anybody know the general rules regarding when assemblies referenced by AssemblyA will be needed by AssemblyB?
Thanks!
Thanks for the quick replies! I thought about simply adding StructureMap as a reference. However, the angle I was going for in my design was to abstract underlying implementations away from the consumer. In other words, Assembly B would be ignorant to the fact that StructureMap was ultimately being used. Also, if I GAC StructureMap, then I would run into deployment issues right? If I deploy a site to a host machine which doesn't have StructureMap in its Global Cache, then I'm back to square one. I'm curious how true abstraction could be realized given this assembly referencing issue.
To avoid copying the DLL, you could add the StructureMap.dll to your project and have VS automatically copy it to the output upon building AssemblyA.
Or, you could use ILMerge to merge StructureMap.dll into Assembly B, and not worry about copying it, as Assembly B will contain all the IL needed.
Or, you can add StructureMap.dll to the Global Assembly Cache, which should allow .NET to find it without having to copy it. However, IIRC, all GAC assemblies need strong names.