Google.OrTools.Sat CPSolver.Solve 导致 AccessViolationException

问题描述 投票:0回答:1

我正在关注这个视频它是用Python编写的,我正在转换为dotnet。

我一运行该应用程序,它就崩溃了。我删除了直到此复制品为止的所有内容。

我只能假设我错过了一些设置。有什么提示吗

程序.cs

using Google.OrTools.Sat; // 9.10.4067

var model = new CpModel();
var solver = new CpSolver();
solver.Solve(model);

// an attempt to prevent the crash as per other SO post - https://stackoverflow.com/questions/47296373/accessviolationexception-when-accessing-variable-solution-value
GC.KeepAlive(model);
GC.KeepAlive(solver);

输出

%USER_PROFILE%\AppData\Local\Programs\Rider\plugins\dpa\DotFiles\JetBrains.DPA.Runner.exe --handle=14376 --backend-pid=6556 --etw-collect-flags=67108622 --detach-event-name=dpa.detach.14376 %LOCAL_PATH%/ConsoleApp1/bin/Debug/net7.0/ConsoleApp1.exe
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at Google.OrTools.Sat.operations_research_satPINVOKE.SolveWrapper_Solve(System.Runtime.InteropServices.HandleRef, Int32, Byte[])
--------------------------------
   at Google.OrTools.Sat.SolveWrapper.Solve(Google.OrTools.Sat.CpModelProto)
   at Google.OrTools.Sat.CpSolver.Solve(Google.OrTools.Sat.CpModel, Google.OrTools.Sat.SolutionCallback)
   at Program.<Main>$(System.String[])

Process finished with exit code 0xC0000005.

项目文件

 <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>
    <ItemGroup>
      <PackageReference Include="Google.OrTools" Version="9.10.4067" />
    </ItemGroup>
</Project>
c# .net-core or-tools
1个回答
0
投票

Visual Studio 2022 中的编译器版本(17.8 与 17.9)之间存在一个严重的错误。请务必遵循https://github.com/google/or-tools/issues/4225中的解决方案。如果它不能解决您的问题,请报告。

© www.soinside.com 2019 - 2024. All rights reserved.