For various reasons, I need to implement a type caching mechanism in C#. Fortunately, the CLR provides Type.GUID
to uniquely identify a type. Unfortunately, I can't find any way to look up a type based on this GUID. There's Type.GetTypeFromCLSID()
but based on my understanding of the documentation (and experiments) that does something very, very different.
Is there any way to get a type based on its GUID short of looping through all the loaded types and comparing to their GUIDs?
EDIT: I forgot to mention that I would really like a "type fingerprint" of fixed width, that's why the GUID is so appealing to me. In a general case, of course, the fully qualified name of the type would work.
If you are in control of these classes I would recommend:
You can generate your GUIDs using Visual Studio, Tools->Create Guid.