如何分发32位和64位版本的库 [英] How to distribute both 32 and 64 bit versions of the library

查看:215
本文介绍了如何分发32位和64位版本的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有被称为由不同的客户端了一个C#库(32位和64位)。到现在为止它被编译成值为anycpu,所以没有问题。

I have a C# library that is called by various clients (both 32-bit and 64-bit). Up to now it was compiled as AnyCPU, so there was no issues.

最近我添加了一个依赖于SQLite的.NET库,来在32位和64位的口味(但不是值为anycpu)。所以,现在,我必须有2构建 - 两个bitnesses。

Recently I added a dependency to SQLite .NET library which come in both 32 and 64-bit flavors (but not AnyCPU). So, now, I have to have 2 builds - for both bitnesses.

在过去,我见过的其他库(MS SQL精简想到)是有一个计划,一个单一的.NET程序集将有私人\ AMD64 私人\ 86 文件夹中的文件夹与他们相应的机库,它会调用根据需要为每个之一。

In the past, I've seen other libraries (MS SQL Compact comes to mind) that had a scheme where a single .NET assembly would have Private\amd64 and Private\x86 folders in the folders with the appropriate native libraries in them and it would call each one as necessary.

这是可行的方法对我的情况?是否有关于如何实现它的文档?是否有需要code值或者这是一个分配技术?

Is this approach viable for my situation? Is there documentation on how to implement it? Are there code changes required or is this a distribution technique?

推荐答案

有几种方法可以处理这个问题。 code的变化(小)所需要的前三个方法:

There are several ways you can handle this. Code changes (small) are required for the first three approaches:

一个。您可以修改路径指向特定于平台的文件夹的应用程序中启动。然后,.NET将自动从该文件夹中加载本地的DLL。

A. You can modify the PATH to point to the platform specific folder during application start up. Then .NET will automatically load local DLLs from that folder.

乙。您可以基于该平台的订阅AssemblyResolve事件,然后选择组件。

B. You can subscribe to the AssemblyResolve event and then choose the assembly based on the platform.

看看这个斯科特Bilias的博客文章<一个href="http://scottbilas.com/blog/automatically-choose-32-or-64-bit-mixed-mode-dlls/">http://scottbilas.com/blog/automatically-choose-32-or-64-bit-mixed-mode-dlls/.请注意,他结束了preferring方法的一个。

Check out Scott Bilias's blog post on this http://scottbilas.com/blog/automatically-choose-32-or-64-bit-mixed-mode-dlls/. Note that he ends up preferring approach A.

简单地说,解决的办法是欺骗装载机!引用不存在的p4dn.dll,并使用AssemblyResolve事件拦截负载,并重新路由到正确的位大小组装。

"In a nutshell, the solution is to trick the loader! Reference a p4dn.dll that does not exist, and use the AssemblyResolve event to intercept the load and reroute it to the correct bit size assembly."

℃。使用特定于平台的集exe.configs和codeBase的元素来确定组件的位置。您的设置将安装正确的基础平台。

C. Use a platform-specific set of exe.configs and the codebase element to determine assembly locations. Your setup would install the correct one based on platform.

<一个href="http://msdn.microsoft.com/en-us/library/4191fzwb.aspx">http://msdn.microsoft.com/en-us/library/4191fzwb.aspx

Ð。写两个设置一个用于32位,另一个用于64位,那么只有安装相应的文件的平台。

D. Write two setups one for 32-bit and one for 64-bit, then only install the appropriate files for the platform.

这篇关于如何分发32位和64位版本的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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