尝试保存 Emitted 程序集时抛出 NotSupportedException

NotSupportedException is thrown when trying to save Emitted assembly

http://pastebin.com/n6G1jTHQ
我的代码创建了一个新程序集和模块,然后发出一个 class SWT(在新程序集中),它应该与 SWTTFieldsclass 完全相同。 第137行,将assembly/module存成.dllmyAsmBuilder.Save("ModuleOne.dll");抛出异常:

An unhandled exception of type 'System.NotSupportedException' occurred in mscorlib.dll Additional information: Type 'SWT' was not completed.

为什么我会收到这个错误?我发出的 class 中缺少什么?

您必须在保存文件之前为每个 TypeBuilder 调用 TypeBuilder.CreateType Method