简体   繁体   English

条件参考

[英]Conditional References

Currently our .net code is not processor specific, but it depends on libraries (Oracle/ODP.Net) which are. 目前我们的.net代码不是特定于处理器的,但它依赖于库(Oracle / ODP.Net)。 We've found a solution where we edit the csproj file directly, and put the references in to item groups with a Condition clause based on our selected build configuration. 我们找到了一个直接编辑csproj文件的解决方案,并根据我们选择的构建配置将引用放入带有Condition子句的项目组中。 We have 32 bit debug/release and 64bit debug/release, and the correct assemblies are references when you build that config. 我们有32位调试/发布和64位调试/发布,并且在构建该配置时正确的程序集是引用。

This works more or less at build time, but it causes all kinds of wackiness in Visual Studio (2008). 这在构建时或多或少有效,但它会在Visual Studio(2008)中引起各种怪异。 The end result is that the same assembly shows up four times under references, and three have the yellow exclamation mark. 最终结果是相同的组件在引用下显示四次,三个具有黄色感叹号。 It also generates some 76 warnings that I can't get rid of. 它还会产生一些我无法摆脱的76个警告。 We try to aim for 0 warnings because we want to know when new ones show up so this is a bit of a problem. 我们试图针对0警告,因为我们想知道什么时候出现新警告,所以这有点问题。

Is anybody aware of a solution to conditional references that allow it to look like a single reference (which it really is) and doesn't fill up my warnings at build time? 是否有人知道条件引用的解决方案允许它看起来像一个引用(它确实是这样)并且在构建时没有填写我的警告?

The only thing that leaps to mind is having 4 separate project files... but before you panic about having to maintain 4 files when ever you add a class, you can use another csproj trick here: 唯一想到的就是拥有4个独立的项目文件......但是在你添加一个类时,在你不得不维护4个文件时,你可以在这里使用另一个csproj技巧:

<Compile Include="**\*.cs" />

which (IIRC) says "include all cs files at any level in the folder structure". 其中(IIRC)说“包括文件夹结构中任何级别的所有cs文件”。

We found an answer that was a bit different than what we were looking for, but I kindof like it. 我们找到了一个与我们想要的有点不同的答案,但我很喜欢它。 If you add this to your config file under runtime->AssemblyBinding 如果在runtime-> AssemblyBinding下将其添加到配置文件中

<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342"  />
<bindingRedirect oldVersion="2.111.6.20" newVersion="2.111.6.0" />
</dependentAssembly>

Then the 64bit and 32bit versions work with the same build. 然后64位和32位版本使用相同的版本。 All we have to do is not copy Oracle.DataAccess.dll locally when we deploy and let it pull it from the GAC. 我们所要做的就是在部署时不在本地复制Oracle.DataAccess.dll,并让它从GAC中提取。

Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM