Hi,
I have created small .NET dll, in which I have exposed a number of
classes for COM interop using ComVisible(true) on those classes, for
example:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class Class1: IClass1
{
private int i;
public int GetInt()
{
return i;
}
}
[ComVisible(true)]
public interface IClass1:IClassBase
{
int GetInt();
}
The assemblyInfo looks like this:
// General Information about an assembly is controlled through the
following
// set of attributes. Change these attribute values to modify the
information
// associated with an assembly.
[assembly: AssemblyTitle("MyLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Primavera Systems")]
[assembly: AssemblyProduct("MyLibrary")]
[assembly: AssemblyCopyright("Copyright Primavera Systems 2005")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not
visible
// to COM componenets. If you need to access a type in this assembly
from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is
exposed to COM
[assembly: Guid("f0ec6621-1a41-406e-b75f-6dd99c5a0380")]
// Version information for an assembly consists of the following four
values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and
Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Now I build it and use regasm.exe to register for COM interop and
create tlb file.
The problem is when I rebuild the dll and register it again, there is a
duplicate entry created for the class in registry with a different
CLSID. If I use unregister using regasm.exe it only unregisters the
later version.
I know I can use:
[assembly: AssemblyVersion("1.0.0.1")]
in AssemblyInfo.cs file to force to regenerate the classes with same
CLSID everytime I build and looks like its working.
I have the following questions:
1. Because I only realized this problem only late in the development
cycle, I see lot of duplicate class entries in the registry with
different CLSID (I see them easily with OLEView.exe), how can get rid
of all these garbage entries easily? are there any tools available or I
have to painstackingly remove hundreds of these entries manually?
2. To solve the problem, I have used strong assembly version. Do I have
to do anything more than this to make sure the CLSID's are always the
same? Specifying this attribute for each class is tedious, and
cumbersome. Any ideas on this.
I really appreciate any help on this, and thanks in advance for the
assistance provided..:)
askingroups@gmail.com - 15 Nov 2005 20:49 GMT
I forgot mention the environment I am using,
I am working on .NET 2.0 beta2 on Windows 2000 advanced server.
TDC - 16 Nov 2005 13:34 GMT
Well, you can always explicilty decalre your GUIDs instead of letting
the compiler/typeexporter create them on the fly.
Tom
askingroups@gmail.com - 16 Nov 2005 20:54 GMT
Thanks for the reply,
Thats what I dont want to do. As I said in one of my questions earlier,
I just want to confirm whether just specifying the assemblyVersion
would suffice to make sure the CLSID's remain same across builds. The
reason I cannot generate GUID's is because the classes and interfaces
are generated so I cannot control the GUID's there.
Is there any tool to cleanup the registry of these duplicate .NET
entries? None of the tools ie, regclean,regcleanr could do the job. I
am planning to write my own to clean them up.
I have seen lot of questions about cleaning up but no answers.