VS2010中的版本更改后,如何保持CLSID不变-二进制兼容性?- [英] How to Keep CLSID constant after a version change in VS2010 - Binary compatibility?-

查看:124
本文介绍了VS2010中的版本更改后,如何保持CLSID不变-二进制兼容性?-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何在VS2010中使用二进制兼容性吗?

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

我有一个项目,每次使用新版本的新程序集文件进行构建时,都会更改dll的CLSID.

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

我已经在WiX软件包中使用了硬编码的CLSID将该dll注册为com +,但是如果要在每个版本上进行更改,则意味着我应该使用evey新版本更新我的WiX软件包.

I already use that CLSID hardcoded in my WiX package to register that dll as a com+ but if it is to change on every build would mean I should update my WiX package with evey new version.

任何想法?

编辑1

我应该提到,此CLSID是在组件服务中通过Newley注册的Com +的属性窗口中的Application ID旁边出现的CLSID.我必须将它们硬编码到WiX文件中,以便在安装时注册

I should mention that this CLSID is the one that appears along side your Application ID in the properties window of your newley registered Com+ in component services. I have to hardcode them into the WiX file so it gets registered on install

编辑2

这里是另一个问题的链接,该问题与我要获取更多信息的内容有关 WiX-注册ComPlus应用程序并将角色分配给组件

Here is a link to another question that is related to what I am asking for more information WiX - Register ComPlus application and Assigning a role to a component

推荐答案

感谢MSDN,我找到了解决方案,

I have found the solution thanks to MSDN,

默认情况下,当您重建装配时,会为其分配一个新的版本号.这是因为Visual Studio .NET将新项目的AssemblyVersion属性设置为"1.0.*".因此,每次重新组装程序集时,都会为服务的组件生成一个新的类标识符(CLSID).

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 serviced components each time the assembly is rebuilt.

注意此行为在C#和Visual Basic .NET项目之间略有不同.对于C#项目,程序集版本在每次重建时都会增加.对于Visual Basic .NET项目,在将项目加载到Visual Studio .NET中后,第一次重新生成该程序集版本是会增加的.在Visual Studio .NET的同一实例中进行的后续重建不会导致程序集版本增加.

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

这并不代表问题,因为程序集版本仅用于提供信息,而不提供强名称.对于强命名程序集,应使用手动维护的静态版本号.此问题和其他版本控制问题将在第5章构建过程"的控制程序集版本"中进一步讨论.

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

为了控制COM +目录中最终使用服务组件的CLSID,并避免每次开发人员重建服务组件时出现多个版本,请使用以下两种方法之一:

In order to control the CLSID that serviced components end up with in the COM+ catalog and avoid multiple versions appearing each time a developer rebuilds the serviced component, use either of the following approaches:

1.通过使用以下Guid属性来明确控制CLSID:

1.Explicitly control the CLSID by 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.为服务组件的程序集维护静态程序集版本号,并且不要使用Visual Studio .NET默认的"1.0.*"版本编号方案.有关程序集版本控制的更多信息,请参见第5章构建过程"中的控制程序集版本".

2.Maintain a static assembly version number for the serviced component's assembly and don't use the Visual Studio .NET default "1.0.*" version numbering scheme. For more information about assembly versioning, see Controlling Assembly Version in Chapter 5, "The Build Process."

我用第一种方法.工作了.

I used the first method. Worked a treat.

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

这篇关于VS2010中的版本更改后,如何保持CLSID不变-二进制兼容性?-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆