Hello,
I have assembly A that depends (statically) on type T (reference type, a class) in assembly B.
I do not own assembly A but I do own assembly B. T unfortunately is a real type (not an interface) but luckily A uses reflection to discover its members.
I want to be able to create dynamically B (and T). The only important item is that I need to be sure that the "B and T" dinamically created (not their members) are "equivalent" tho those that were statically compiled when A was compiled.
- I can use reflection Emit to create B and T. No problem.
- I can write B.dll to disk
- If A was compiled against this B.dll then I can dinamically change T, no problem
- However if A was compiled against a equivalent (hand written B and T) then the T' in A would have the same assembly name and type name but it would not be considered equal to the one dinamically created.
I assume that the reason is the GUID property on the type. When I write B.dll to disk the T type has the same GUID than the one I can create dynamically (even if I change its members). However the "otherwise equivalent" hand-written type does not share the same GUID.
In summary the GUID is the same if the dll comes from the dinamically created but is different from the one statically created. The GUID is the same every time (even if I recompile). The GUID is the same if I change the content of the dynamic Type.
How does the runtime determine if two types are the same? How is this GUID created? It uses this GUID and/or something else? Is it possible to assign this GUID in my dimamic assembly to match the one in assembly A?
Can this GUID be examined statically (I was not able to see it with Reflector or ildasm).
NOTE: Assume assemblies are not signed.