Hello all. I am using VS2010 with .NET 4
I have some code that looks in a directory for any dlls and then finds the one that contains the correct exports and reads it in.
The code is below:
The dll that I'm trying to load implements the proper interface
var catalog = new AggregateCatalog();
_container = new CompositionContainer(catalog);
string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string roofcalcPath = Path.Combine(exePath, "roofcalc");
// where to find the calculator DLL
catch (ReflectionTypeLoadException rtle)
Type err = rtle.Types;
// Load calculator DLL, create and store reference to object instances
// that are marked Import in this class.
// expected exception of calculator DLL is not present in the directory
Calculator = null;
It works perfectly and is able to read the dll and perform the functions when I use the DEBUG version of the dll, however when I use the RELEASE version I get the following error message
public class GPiStructHelper : IRoofCalc
/// Call this from iStruct to pass in the structural data and
/// return a list of reaction loads to be further processed by iStruct
/// <param name="structureData"></param>
ResultData IRoofCalc.CalculateReactions(StructureData structureData)
//convert iStruct data to GP data
//Design each member
List<GPRoofMember> rfMembers = new List<GPRoofMember>();
List<GPColumnBracing> cols = new List<GPColumnBracing>();
List<GPStrongback> strgbks = new List<GPStrongback>();
foreach (KeyValuePair<long, GPObject> gpObject in StaticGPiStructHelper.StructuralItems)
if (gpObject.Value is GPRoofMember)
GPRoofMember target = gpObject.Value as GPRoofMember;
if (gpObject.Value is GPStrongback)
GPStrongback stbk = gpObject.Value as GPStrongback;
if (gpObject.Value is GPColumnBracing)
GPColumnBracing col = gpObject.Value as GPColumnBracing;
if (col.GetOwner() == 0)
foreach(GPRoofMember target in rfMembers)
//Transfer loads for strongbacks and bracing
foreach (GPStrongback stbk in strgbks)
foreach(GPColumnBracing col in cols)
//convert data from GP to iStruct
Sample IRoofCalc.CalcWithData(Sample samp)
string msg = "Not implemented";
The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) No valid exports were found that match the constraint '((exportDefinition.ContractName == "StructuredDesign.RoofCalcInterface.IRoofCalc") AndAlso (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity") AndAlso "StructuredDesign.RoofCalcInterface.IRoofCalc".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))', invalid exports may have been rejected.
Resulting in: Cannot set import 'GPAddonTestHarness.Host.Calculator (ContractName="StructuredDesign.RoofCalcInterface.IRoofCalc")' on part 'GPAddonTestHarness.Host'.
Element: GPAddonTestHarness.Host.Calculator (ContractName="StructuredDesign.RoofCalcInterface.IRoofCalc") --> GPAddonTestHarness.Host
Please help me figure out what the heck is going on.