C#的Visual Studio:如何对引用的Office解决方案开发人员多张? [英] C# Visual Studio: How to have mulitple developers on a solution that references Office?

查看:1038
本文介绍了C#的Visual Studio:如何对引用的Office解决方案开发人员多张?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我添加到Office COM库的引用,我去:

When i add a reference to Office COM Library, i to go:


  • 参考

  • 添加引用

  • 选择 COM标签

  • 选择的Microsoft Office 12.0对象库

  • References
  • Add Reference
  • Select the COM tab
  • Select Microsoft Office 12.0 Object Library

和神奇出现名为参考:

Microsoft.Office.Core

Microsoft.Office.Core

Project.csproj 文件显示引用的详细信息:

The Project.csproj file shows the details of the reference:

<COMReference Include="Microsoft.Office.Core">
   <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
   <VersionMajor>2</VersionMajor>
   <VersionMinor>4</VersionMinor>
   <Lcid>0</Lcid>
   <WrapperTool>primary</WrapperTool>
   <Isolated>False</Isolated>
</COMReference>

我检查项目源代码控制,现在没有人可以生成解决方案;他们没有Office 12中,他们只有11处。

i check the project into source control, and now nobody else can build the solution; they do not have Office 12, they only have Office 11.

另一个人检查出的.csproj文件,删除引用:

Another guy checks out the .csproj file, deletes the reference to:

Microsoft Office 12.0 Object Library

和重新添加COM引用如下:

and re-adds the COM reference as:

Microsoft Office 11.0 Object Library

在此之后,和新参考将出现在解决方法:

After that, and new reference appears in the Solution:

Microsoft.Office.Core

Project.csproj 文件显示引用的详细信息:

and the Project.csproj file shows the details of the reference:

<COMReference Include="Microsoft.Office.Core">
  <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
  <VersionMajor>2</VersionMajor>
  <VersionMinor>3</VersionMinor>
  <Lcid>0</Lcid>
  <WrapperTool>primary</WrapperTool>
  <Isolated>False</Isolated>
</COMReference>

注意:读者谁看的问题就明白了这个问题。这是同样的类型库,但版本2.3相对于2.4版本。

Note: Readers who read the question will understand the problem. It's the same type library, but version 2.3 as opposed to version 2.4.

该项目然后签入源代码控制,现在开发商的Office 2007(和Office 2000为此事)不能建立,因为Visual Studio中无法解析的引用:

The project is then checked into source control, and now developers with Office 2007 (and Office 2000 for that matter) cannot build it, because Visual Studio cannot resolve the reference to:

{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}\2.3\0\primary



我们显然需要一个版本独立的方式来引用处。

We obviously need a version independant way to reference Office.

我们如何引用Office的版本,开发人员构建它自己的机器上已经intsalled?

How do we reference the version of Office that the developer building it on his machine has intsalled?

如何我们有多个开发人员引用的Office解决方案的工作?

How do we have multiple developers work on a solution that references Office?


注意:这个问题是相同的,但是从另一个问题#2根本不同的如何从Visual Studio C#使用Office?

Note: This question is identical to, but fundamentally different from, another Stackoverflow question How to use Office from Visual Studio C#?

从尝试使用Office从Visual Studio整套的问题,这个问题的交易。这个问题只集中在一个特定的问题。

That question deals with the entire set of problems from trying to use Office from Visual Studio. This question only focuses on one specific problem.

推荐答案

摘要您code,使所有的code触及办公室是在一个单独的项目。然后,你可以有两个项目 - 一个用于办公室11,一个用于办公室12。然后从你的应用程序中引用这两个项目。如果两个类实现共同的接口,那么你可以使用工厂模式来实例化一个合适的和使用的功能,而无需重新编译。

Abstract your code so that ALL of the code that touches Office is in a separate project. Then you can have two projects - one for Office 11 and one for Office 12. Then reference both projects from your application. If the classes both implement a common interface, then you can use a factory pattern to instantiate the appropriate one and use the features without having to recompile.

这篇关于C#的Visual Studio:如何对引用的Office解决方案开发人员多张?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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