Under cpython 2.5.1 and Microsoft .NET 2.x, CodeGenerator's ctor was causing an exception when calling Thread.GetDomain().DefineDynamicAssembly. A "fix" for this seems to be to make this call happen before Python.Runtime.Runtime.Initialize(). To do this, CodeGenerator is no longer a static class (along with the classes that use it). DelegateManager (the owner of the only CodeGenerator instance) is then created in PythonEngine.Initialize, ahead of the Runtime.Initialize() call. This "fix" is probably masking some bad mojo happening somewhere down in Runtime.Initialize().