HighTechTalks DotNet Forums  

registering for COM interop creating duplicate registry entries.

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss registering for COM interop creating duplicate registry entries. in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default registering for COM interop creating duplicate registry entries. - 11-14-2005 , 09:31 PM






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..


Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: registering for COM interop creating duplicate registry entries. - 11-15-2005 , 03:49 PM






I forgot mention the environment I am using,

I am working on .NET 2.0 beta2 on Windows 2000 advanced server.


Reply With Quote
  #3  
Old   
TDC
 
Posts: n/a

Default Re: registering for COM interop creating duplicate registry entries. - 11-16-2005 , 08:34 AM



Well, you can always explicilty decalre your GUIDs instead of letting
the compiler/typeexporter create them on the fly.

Tom


Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: registering for COM interop creating duplicate registry entries. - 11-16-2005 , 03:54 PM



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.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.