Thanks for replying Jon
Creating a type from a form
The form returns to this method an arraylist of TypeObjects the object contains 2 strings, name and type. example: "Width" "System.Int32
I try to match the types at the end and my messageboxes tell me the results
The first messageBox matches fine
Then I save and load the assembly and attempt a further match, this one is always false, in debugger the loaded assembly has no types
AssemblyName an = new AssemblyName()
an.Name = "myAssembly"
AppDomain currentDomain = AppDomain.CurrentDomain
AssemblyBuilder ab = currentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.RunAndSave)
ModuleBuilder mb = ab.DefineDynamicModule("myModule")
TypeBuilder tBuild = mb.DefineType("myType", TypeAttributes.Public)
foreach(TypeObject to in alTypeObjects
tBuild.DefineField(to.name, System.Type.GetType(to.type),FieldAttributes.Private)
System.Type[] types = new System.Type[1]
types[0] = System.Type.GetType(to.type)
tBuild.DefineProperty(to.type.ToUpper(), PropertyAttributes.HasDefault, System.Type.GetType(to.type), types);
Type theType = tBuild.CreateType()
object o = Activator.CreateInstance(theType)
Type aType = mb.GetType("myType")
if(aType == theType
MessageBox.Show("Type match")
ab.Save("myassembly.dll")
Assembly a = Assembly.LoadFrom("myassembly.dll")
aType = a.GetType("myType")
if(aType == theType
MessageBox.Show("Type match")
els
{MessageBox.Show("2nd match not found");}