繁体   English   中英

如何在 C# 应用程序中嵌入或工具?

[英]How to embed or-tools in a C# application?

我正在尝试按照https://developers.google.com/optimization/introduction/installing.html#windows_binary中的说明进行操作,以便可以在 C# 应用程序中使用或工具。

我被困在make all步骤上。 我在开发人员命令提示符中,但是这个命令说:

'make' is not recognized as an internal or external command,
operable program or batch file.

我尝试下载 GNU make,但也失败了。 make install说“没有目标”,而一个裸露的make说:

process_begin: CreateProcess(NULL, cl /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo /O2 -DNDEBUG -DUSE_CBC -DUSE_CLP /D__WIN32__ /Iinclude\src\windows /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /Iinclude /Iexamples -DUSE_GLOP -DUSE_BOP -c examples\cpp\costas_array.cc /Foobjs\costas_array.obj, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [objs\\costas_array.obj] Error 2

我还尝试将 DLL 从bin文件夹直接复制到我的项目中。 我可以通过这样做来针对它们进行编译,但是当我尝试运行它时出现错误:

System.BadImageFormatException: 'Could not load file or assembly 'Google.OrTools, Version=5.1.6235.37215, Culture=neutral, PublicKeyToken=7a052e3db761d3be' or one of its dependencies. An attempt was made to load a program with an incorrect format.'

我错过了什么?

关于 System.BadImageFormatException:

OrTools 二进制格式以 64 位 dll 提供。

确保您的项目设置为 64 位:

在 Visual Studio 中,您可以通过右键单击项目 --> 属性 --> 构建,平台目标来检查它:这应该设置为 x64。

In case you have the same issue with web application, just enable 64 bits on IIS Express using Tools -> Options -> Projects and Solutions -> Web Projects -> Use the 64-bit version on IIS Express for web sites and projects 视觉工作室 2019

我在 Web 应用程序中使用 OR-Tools 时遇到了这个问题(它在控制台应用程序中运行良好)。 我得到:

System.BadImageFormatException HResult=0x8007000B 消息=无法加载文件或程序集“Google.OrTools”或其依赖项之一。 试图加载格式不正确的程序。

使用 x64 没有帮助,而且 Octopus 也没有正确构建项目。 对我有用的解决方案是在项目的.csproj 中指定要使用的 ASPNETCOMPILER (x64):

<Project .... >
   <PropertyGroup>
      <AspNetToolPath>$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspNetToolPath>
   </PropertyGroup>

暂无
暂无

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

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