如何分发32位和64位版本的库

编程入门 行业动态 更新时间:2024-10-24 01:49:46
本文介绍了如何分发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的博客文章scottbilas/blog/automatically-choose-32-or-64-bit-mixed-mode-dlls/.请注意,他结束了preferring方法的一个。

Check out Scott Bilias's blog post on this scottbilas/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.

msdn.microsoft/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位版本的库

本文发布于:2023-07-05 09:01:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1035501.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!