在C#中使用Microsoft Solver Foundation

bet*_*ris 5 c# ms-solver-foundation

我正在尝试在VS2010 Ultimate的C#应用​​程序中使用Microsoft Solver Foundation.我已经安装了MSF(64位版本),据我所知,我应该能够在声明之后使用这些服务:

using Microsoft.SolverFoundation;
Run Code Online (Sandbox Code Playgroud)

但是,我收到错误"类型或命名空间名称'SolverFoundation'在命名空间'Microsoft'中不存在".

我看到Microsoft.Solver.Foundation.dll位于C:\ Program Files(x86)\ Reference Assemblies\Microsoft\Framework.NETFramework\v4.0

最初我认为64位版本可能是问题所以我卸载并切换到32位版本.但也没有成功.

如何将MSF集成到我的C#应用​​程序中?

jas*_*son 6

我正在尝试在VS2010 Ultimate的C#应用​​程序中使用Microsoft Solver Foundation.我已经安装了MSF(64位版本),据我所知,我应该能够在声明之后使用这些服务:

using Microsoft.SolverFoundation;
Run Code Online (Sandbox Code Playgroud)

如何将MSF集成到我的C#应用​​程序中?

您没有提到您在项目中添加了对此库的引用,并且您描述的行为与未添加引用一致.因此,您还需要向项目添加对此库的引用.


bet*_*ris 6

我之前已经尝试过添加引用但它不起作用.现在我注意到了警告中的一些内容(我之前可能没有看到):

"The referenced assembly "Microsoft.Solver.Foundation, Version=3.0.1.10599, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project."
Run Code Online (Sandbox Code Playgroud)

我通过将".Net Framework 4 Client Profile"中的Application Properties - > Application - > Target Framework设置为".Net Framework 4"来解决此问题.

  • 正确,您需要让您的项目以完整的.NET 4框架为目标,它不适用于客户端配置文件. (2认同)