How to keep CLSID constant after version change in VS2010 - Binary Compatibility? -

Can someone tell me how can I use binary compatibility in VS2010?

I have a project that in evertime that I build with a new build file with a new version changes the CLSID for the dll.

I already use this CLSID, hardcoded in my WiX package, to register this DLL as com +, but if this needs to be changed in every build, that means I have to update my WiX package with the new version of evey.

Any ideas?

Edit 1

I have to mention that this CLSID is the one that appears next to your application ID in the properties window of your new Com + service in components. I have to hardcode them into the WiX file so that it registers on install

Edit 2

Here is a link to another question related to the fact that I am asking for more WiX information - register the ComPlus app and assign a role to the component

+1


source to share


1 answer


I found a solution thanks to MSDN,

By default, when you rebuild an assembly, it is assigned a new version number. This is because Visual Studio.NET sets the AssemblyVersion attribute to "1.0. *" For new projects. As a result, a new class identifier (CLSID) is generated for each serviced component each time the assembly is rebuilt.

Note This behavior is slightly different between C # and Visual Basic.NET projects. For C # projects, the version of the assembly is incremented every time it is rebuilt. For Visual Basic .NET projects, the assembly version is incremented the first time you restore the project after loading it in Visual Studio .NET. Subsequent rebuilds in the same Visual Studio .NET instance do not increase the assembly version.

This is not a problem because the assembly version is for information only in assemblies that do not have a strong name. For strong named assemblies, you must use static version numbers that are manually maintained. This and other versioning issues are discussed further in the Controlling Assembly version in Chapter 5, The Assembly Process.

To manage the CLSID that serves components in the COM + catalog and to avoid multiple versions each time a developer rebuilds the serviced component, use one of the following methods:



1. Manage the CLSID explicitly using the following Guid attribute:

[Guid("2136360E-FEBC-475a-95B4-3DDDD586E52A")]
public interface IFoo
{}

[TransactionAttribute(TransactionOption.Required),
Guid("57F01F20-9C0C-4e63-9588-720D5D537E66")]
public class Foo: ServicedComponent, IFoo
{}

      

2. Keep the version number of the static assembly for the serviced component assembly and do not use the standard 1.0 version numbering. * * for Visual Studio .NET. For more information on versioning assemblies, see the section Versioning an assembly in Chapter 5, The Build Process.

I used the first method. I worked with pleasure.

http://msdn.microsoft.com/en-us/library/ee817675.aspx

+1


source







All Articles