removing registry garbages
-
Hi guys, When i want to reference one com object in my project i can see 3 or 4 object with the same name and version but different path, ( it 's for tlb file) is there any way i can clean my registry content up for those library, for example is there any method like this RemoveRegistry(GUID ClassGUID) then it removes all of the registry content for that library. thanx in advance:confused:
-
Hi guys, When i want to reference one com object in my project i can see 3 or 4 object with the same name and version but different path, ( it 's for tlb file) is there any way i can clean my registry content up for those library, for example is there any method like this RemoveRegistry(GUID ClassGUID) then it removes all of the registry content for that library. thanx in advance:confused:
The reason you see multiple typelib references is because they are using different GUIDs, so even if such a function existed (which it doesn't, but it isn't hard to create) it would be effective because each typelib is registering with a different GUID (otherwise you wouldn't see multiple references). Remove them manually by searching for your typelib using regedit.exe. The thing to do is eliminate the problem. You MUST use hard-coded GUIDs using the
GuidAttribute
for all classes and interfaces that are exposed as COM objects and interfaces. The GUID on the interface should NEVER change. If you need a new interface, implement the previous version of the interface and create a new one (like IMyInterface2), giving it a new GUID. The class GUID should typically not change. To solve your immediately problem, you should also use an assembly-levelGuidAttribute
for your assembly, which is used as the typelib ID when a typelib is generated:[assembly: Guid("cac7a0f0-c3a7-4039-abd7-1bc55b924bd7")]
(Generate your own, though) When you register your class using regasm.exe /tlb <filename> now, the typelib will always have the same GUID and only the last path you registered will exist in the registry. You should read those links I gave a while back discussing exposing .NET controls as COM objects. It does discuss this as well.
Microsoft MVP, Visual C# My Articles