<html><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div style="font-family: 'lucida console', sans-serif; font-size: 10pt;">Brian,</div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">Just wanted to share something with you in case it helps the cause. I was having real trouble getting a custom assembly compiled against 4.0 framework to import. Technically, it was the open source EPPlus.dll library and I could add it fine via clr.AddReference("EPPlus") but the import step failed saying "No module named OfficeOpenXml".</div><div style="font-family: 'lucida console',
 sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">Here's where it gets strange ... the *exact* same source code against the *exact* same target framework 4.0 created slightly different .dll's when compiled from VS2010 vs 2012. The one compiled using Vs2010 had no problems being imported into python.net but the Vs2012 exhibited the behavior above.</div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">It turns out that there's a subtle thing going on:</div><div style="font-family: 'lucida console',
 sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">1) You<span style="background-color: transparent;">r ScanAssembly() method inside assemblymanager.cs iterates over all the types in the assembly to deduce namespaces and adds them to a new dictionary object (ok so far)</span></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="background-color: transparent;"><br></span></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="background-color: transparent;">2) But the 2012-compiled ,dll and the 2010-compiled .dll seem to have their
 assembly.GetTypes() in slightly different order and your extra "if (t.IsGenericTypeDefinition) {GenericUtil.Register(t);}" piece of this </span><span style="font-size: 10pt;">ScanAssembly() method was running into some generic types w/o a namespace in the 2012-compiled .dll "sooner" than they're listed in the 2010-compiled .dll and blowing things up before any namespaces could be added</span></div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="font-size: 10pt;"><br></span></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="font-size: 10pt;">To make a long story short, here's what I changed and then all worked again for me:</span></div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; color: rgb(0, 0, 0);
 background-color: transparent; font-style: normal;"><span style="font-size: 10pt;"><br></span></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="font-size: 10pt; font-weight: bold;">BEFORE:</span></div><div style="background-color: transparent;"><font face="lucida console, sans-serif" style="font-size: 10px;">if (t.IsGenericTypeDefinition) {</font></div><div style="background-color: transparent;"><font face="lucida console, sans-serif" style="font-size: 10px;">   GenericUtil.Register(t);</font></div><div style="background-color: transparent;"><font face="lucida console, sans-serif"><span style="font-size: x-small;"></span></font></div><div style="background-color: transparent;"><font face="lucida console, sans-serif" style="font-size: 10px;">}</font></div><div style="font-family: 'lucida console', sans-serif; font-size:
 10pt;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="font-size: 10pt;"><br></span></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="font-size: 10pt; font-weight: bold;">AFTER:</span></div><div style="background-color: transparent;"><font face="lucida console, sans-serif" style="font-size: 10px;">if (ns != null && t.IsGenericTypeDefinition) {</font></div><div style="background-color: transparent;"><font face="lucida console, sans-serif" style="font-size: 10px;">   GenericUtil.Register(t);</font></div><div style="background-color: transparent;"><font face="lucida console, sans-serif"><span style="font-size: x-small;"></span></font></div><div style="font-family: 'lucida console', sans-serif; font-size:
 10pt; background-color: transparent;"><span style="font-size: 10pt;"></span></div><div style="background-color: transparent;"><font face="lucida console, sans-serif" style="font-size: 10px;">}</font></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="font-size: 10pt;"><br></span></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">By the way, I was able to compile a new "Python.Runtime.dll" and "clr.pyd" (aka, clrmodule.dll) against 4.5 using Visual Studio 2012 without any problems and load in said EPPLus.dll compiled against 4.5 within my python script. I'm not sure how robust your module is against a heavy RAM/CPU/IO load, but it's definitely intriguing to be able to tap into .NET 4.0/4.5 assemblies from python!!</div><div style="font-family:
 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">Cheers,</div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">Tom</div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif;
 font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div></div></body></html>