简体   繁体   English

结合C ++ / CLI,x86,x64和强命名

[英]Combining C++/CLI, x86, x64 and strong naming

Let me get right to the point: 让我说清楚一点:

Main application: 主要应用:

C# (4.0), AnyCPU. C#(4.0),任何CPU。

Library: 图书馆:

Wrapper for native .dll written in C++/CLI. 用C ++ / CLI编写的本机.dll的包装。 Compiled in two versions; 编译有两个版本; x86 and x64, both signed with the same .snk key (using this workaround) x86和x64,都使用相同的.snk密钥签名(使用替代方法)

Limitations: 局限性:

In the end a single distribution package is required for x86 and x64 platforms. 最后,x86和x64平台需要一个分发包。 Main application needs strong name due to references to other strongly named libs. 主应用程序需要强名称,因为要引用其他强命名的库。 Rewriting the library using managed C# and P/Invoke is an absolute last way out. 使用托管C#和P / Invoke重写库绝对是最后的出路。

The problem: 问题:

As long as the main application, at compile time, references the version (x86 or x64) of the library that is needed when run, this is all working fine. 只要主应用程序在编译时引用运行时所需的库版本(x86或x64),就可以正常工作。

Moving the same compiled output - and exchanging the library with the right platform version during installation - does not work since the signature of the library changes from that of the referenced one. 移动相同的编译输出-并在安装期间将库与正确的平台版本交换-不起作用,因为库的签名与引用的库的签名有所不同。

In a test application without any strong naming I can switch between them as needed. 在没有任何强大命名的测试应用程序中,我可以根据需要在它们之间切换。

The question: 问题:

Is there a way to enable switching between the x86 and x64 libraries within the set limitations, or is strong naming preventing any possible solution other than rewriting the lib? 有没有一种方法可以在设置的限制范围内在x86库和x64库之间进行切换,还是强命名功能会阻止除了重写lib之外的任何可能的解决方案?

Let me clarify that it is not a question about finding the correct .dll (as discussed here ) but about being able to load the .dll once found. 让我澄清一下,这不是一个找到正确的.dll文件(如讨论的问题在这里 ),但对能够装载一旦发现该.dll。

@Damien_The_Unbeliever's comment got me thinking and he is right in that the strong names are the same, and it was not the actual issue. @Damien_The_Unbeliever的评论让我思考,他是对的,因为强者名字相同,但这不是实际的问题。

I found another difference between the two versions of the library; 我发现库的两个版本之间还有另一个区别。 the output name was set to nnn.dll and nnnx64.dll . 输出名称设置为nnn.dllnnnx64.dll Changing it so that both have the same output name magically made it all work. 对其进行更改,以使它们都具有相同的输出名称,即可神奇地完成所有工作。

Perhaps someone knows why such a setting matters, I certainly don't. 也许有人知道为什么这样的设置很重要,我当然不知道。

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

相关问题 在x64模式下运行时,是否可以生成x86哈希值? - Can you generate an x86 hash value when running in x64 mode? C#exe在目标平台x86上不起作用 - C# exe not working on target platform x86 潜在的 .NET x86 JIT 问题? - Potential .NET x86 JIT issue? 与x86平台一起显示的VS2010项目 - VS2010 project showing with x86 platform 在x86平台解决方案中编译共享项目 - Compiling shared project in solution for x86 platform 与emgu.cv x86文件夹混淆 - Confusion with emgu.cv x86 folder 在Windows Azure Cloud上基于x86的C#控制台应用程序中的WebRole和WorkerRole外部托管WCF服务 - Hosting a WCF Service outside a WebRole and WorkerRole in x86 based C# console application on Windows Azure Cloud 找不到导入的项目“ C:\\ Program Files(x86)\\ MSBuild \\ Microsoft \\ VisualStudio \\ v10.0 \\ WebApplications \\ Microsoft.WebApplication.targets” - The imported project “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets” was not found ..obj \\ x86 \\ Release中的VS安装项目目标app.config - VS Setup Project target app.config in ..obj\x86\Release 用于x64位版本的Microsoft.Jet.OLEDB.4.0提供程序的备用解决方案 - Alternate solution of Microsoft.Jet.OLEDB.4.0 provider for x64 bit version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM