public static Type CreateClassType(UInt32 classId, Guid projectGuid) { Type t = VPLUtil.GetClassType(classId, projectGuid); if (t == null) { ClassPointer root = null; LimnorProject prj = LimnorSolution.GetLimnorProjectByGuid(projectGuid); if (prj != null) { root = ClassPointer.CreateClassPointer(classId, prj); } string typename = null; if (root != null) { typename = root.Name; } if (string.IsNullOrEmpty(typename)) { typename = string.Format(CultureInfo.InvariantCulture, "Class_{0}_{1}", classId, projectGuid.ToString("N", CultureInfo.InvariantCulture)); } string name = string.Format(CultureInfo.InvariantCulture, "{0}{1}", VPLUtil.ASSEMBLYNAME_PRE, classId.ToString("x", CultureInfo.InvariantCulture)); AssemblyName aName = new AssemblyName(name); AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly( aName, AssemblyBuilderAccess.RunAndSave); // For a single-module assembly, the module name is usually // the assembly name plus an extension. ModuleBuilder mb = ab.DefineDynamicModule(aName.Name, aName.Name + ".dll"); TypeBuilder tb = mb.DefineType( typename, TypeAttributes.Public, typeof(ClassPointerX)); ConstructorInfo cif = typeof(ClassIdAttribute).GetConstructor(new Type[] { typeof(UInt32), typeof(string) }); CustomAttributeBuilder cab = new CustomAttributeBuilder(cif, new object[] { (UInt32)classId, projectGuid.ToString("N", CultureInfo.InvariantCulture) }); tb.SetCustomAttribute(cab); t = tb.CreateType(); VPLUtil.SetClassType(classId, projectGuid, t); } return(t); }