如何在 Azure 上部署 64 位版本的 DLL,但在开发盒上使用 32 位版本

发布于 2024-12-04 16:19:28 字数 789 浏览 0 评论 0原文

我和我的业务合作伙伴正在共同开发一个部署在 Azure 上的 Web 应用程序。我的盒子基于64位Windows 7,但我的合作伙伴使用32位Windows 7

在 VS2010 IDE 中,当我从 System32 目录(我的机器上的 64 位)添加对“ieframe.dll”的引用时,IDE 实际上带来了 SysWoW64(32 位)版本DLL。

两个开发盒都可以与 32 位 WOW 版本的“ieframe.dll”完美配合,但是当我们部署到 Azure 时,我们在创建 Interop/ 时遇到 EntryPointNotFoundException DllImport 调用“ieframe.dll”。所以看来 Azure 希望拥有 64 位版本。

我们如何将 64 位版本部署到 Azure,同时在开发盒上继续使用 32 位版本?

编辑:显然,我们可以通过将 64 位“ieframe.dll”复制到某处,然后手动将其放入“bin”目录中来手动执行此操作,但是在 Azure 中是否有更好的最佳实践方法来执行此操作?

编辑 #2:对于这种情况,我们最终将 Azure 的节点从 osFamily="1" 更改为 osFamily="2"。执行此操作将安装包含 IE8(而不是 Windows Server 2008 SP1 中的 IE7)的 Windows Server 2008 R2。无需搞乱 32 位版本与 64 位版本,也无需手动将 DLL 复制到服务器。

My business partner and I are co-developing a web app that's deployed on Azure. My box is based on 64-bit Windows 7, but my partner is using 32-bit Windows 7.

From within the VS2010 IDE when I added a reference to 'ieframe.dll' from my System32 directory (64-bit on my box), the IDE actually brought over the SysWoW64 (32-bit) version of the DLL.

Both dev boxes work perfectly with the 32-bit WOW version of 'ieframe.dll', but when we deploy to Azure we're getting a EntryPointNotFoundException when making an Interop/DllImport call into 'ieframe.dll'. So it seems like Azure wants to have the 64-bit version.

How can we deploy the 64-bit version to Azure but keep using the 32-bit version on our dev boxes?

EDIT: Obviously, we can do this manually by copying 64-bit 'ieframe.dll' somewhere and then manually place it in the 'bin' directory, but is there a better best-practice way to do this in Azure?

EDIT #2: For this scenario, we ended up changing the node for Azure from osFamily="1" to osFamily="2". Doing this installs Windows Server 2008 R2 which includes IE8 (rather than IE7 in Windows Server 2008 SP1). No need to mess with 32 versus 64 bit versions or manually copy DLLs up to the server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤单情人 2024-12-11 16:19:28

如果始终从 64 位计算机部署到 Azure,则可以更改项目文件,以便在生成时根据执行生成的计算机的处理器类型将正确的 DLL 复制到 bin 文件夹。这对我们来说非常有用,因为我们从 64 位构建服务器部署到 Azure。如果这听起来像是一个不错的解决方案,请按照下列步骤操作:

1 - 创建一个外部 lib 文件夹,其中包含两个名为 32 和 64 的子文件夹。
2 - 将 32 位版本的 DLL 放在 32 文件夹中,将 64 位版本放在 64 文件夹中。
3 - 在文本编辑器中打开有问题的项目文件。
4 - 将以下节点添加到项目文件中包含“引用包含”项的 ItemGroup 后面。这将根据系统提供的环境变量复制正确的 DLL:

<ItemGroup>
    <DllToCopy Condition=" '$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PROCESSOR_ARCHITEW6432)' == '' " Include="..\ext-lib\32\mydll.dll" />
    <DllToCopy Condition=" '$(PROCESSOR_ARCHITECTURE)' == 'AMD64' Or '$(PROCESSOR_ARCHITEW6432)' == 'AMD64' " Include="..\ext-lib\64\mydll.dll" />
</ItemGroup>

5 - 最后,更改项目的 BeforeBuild 目标,如下所示:

<Target Name="BeforeBuild">
    <Copy SourceFiles="@(DllToCopy)" DestinationFolder="$(OutputPath)" />
</Target>

另一种选择是根据构建配置将正确的 DLL 复制到 bin 文件夹(不太理想)。例如,如果您有一个名为 Production 的构建配置,您将按照上述步骤进行操作,但步骤 4 将包含以下内容:

<ItemGroup>
    <DllToCopy Condition=" '$(Configuration)' != 'Production' " Include="..\ext-lib\32\mydll.dll" />
    <DllToCopy Condition=" '$(Configuration)' == 'Production' Include="..\ext-lib\64\mydll.dll" />
</ItemGroup>

还有一个(甚至不太理想的)选项是将 DLL 的 64 位版本复制到 bin使用 Azure 启动任务的文件夹。

希望这有帮助。

If you are always deploying to Azure from a 64-bit machine, you can alter the project file to copy the correct DLL to the bin folder at build time based on the processor type of the machine performing the build. This works great for us because we deploy to Azure from a 64-bit build server. If this sounds like a good solution, follow these steps:

1 - Create an external lib folder that contains two sub folders named 32 and 64.
2 - Place the 32-bit version of the DLL in the 32 folder and the 64-bit version in the 64 folder.
3 - Open the offending project file in a text editor.
4 - Add the following node to the project file just after the ItemGroup that conatins the "reference include" items. This will copy the correct DLL based on system supplied environment variables:

<ItemGroup>
    <DllToCopy Condition=" '$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PROCESSOR_ARCHITEW6432)' == '' " Include="..\ext-lib\32\mydll.dll" />
    <DllToCopy Condition=" '$(PROCESSOR_ARCHITECTURE)' == 'AMD64' Or '$(PROCESSOR_ARCHITEW6432)' == 'AMD64' " Include="..\ext-lib\64\mydll.dll" />
</ItemGroup>

5 - Finally, alter the project's BeforeBuild target like so:

<Target Name="BeforeBuild">
    <Copy SourceFiles="@(DllToCopy)" DestinationFolder="$(OutputPath)" />
</Target>

Another option would be to copy the correct DLL to the bin folder based on a build configuration (less ideal). For example, if you had a build configuration named Production you'd follow the steps above, except step 4 would contain this:

<ItemGroup>
    <DllToCopy Condition=" '$(Configuration)' != 'Production' " Include="..\ext-lib\32\mydll.dll" />
    <DllToCopy Condition=" '$(Configuration)' == 'Production' Include="..\ext-lib\64\mydll.dll" />
</ItemGroup>

Yet another (and even less ideal) option would be to copy the 64-bit version of the DLL to the bin folder using an Azure startup task.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文