2011-07-13 78 views
5

我試圖在我的C#應用​​程序中使用Microsoft Solver Foundation在VS2010 Ultimate中。我已經安裝了MSF(64位版本),而據我瞭解,我應該能夠使用該服務後宣佈:在C#中使用Microsoft Solver Foundation#

using Microsoft.SolverFoundation; 

不過,我得到錯誤「的類型或命名空間名稱SolverFoundation「不不存在於名稱空間「Microsoft」中。

我看到有Microsoft.Solver.Foundation.dll位於C:\ Program Files文件(x86)的\參考大會\微軟\ Framework.NETFramework \ V4.0

起初我還以爲64位版本可能是問題,所以我卸載並切換到32位版本。但是也沒有成功。

如何將MSF整合到我的C#應用​​程序中?

回答

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." 

我通過設置應用程序屬性修正了這個>目標框架從「.Net框架4客戶端配置文件」到「.Net Framework 4」。

+2

正確,您需要讓您的項目以完整的.NET 4框架爲目標,但它不適用於客戶端配置文件。 – Mathias

6

我想在我的C#應用​​程序在VS2010旗艦版中使用Microsoft Solver Foundation。我已經安裝了MSF(64位版本),而據我瞭解,我應該能夠聲明後使用的服務:

using Microsoft.SolverFoundation; 

如何集成MSF到我的C#應用​​程序?

您沒有提到您爲該項目添加了對該庫的引用,並且您描述的行爲與未添加引用一致。因此,您還需要將此庫的add a reference添加到您的項目中。

0

您需要添加對您找到的DLL的引用。

1

當您訪問Add Reference...時,「Microsoft Solver Foundation」會顯示嗎?

如果沒有使用正確的框架,請嘗試Project -> Properties.. -> Compile -> Advanced Compile Options...並證明您沒有使用.NET 4 Framework Client Profile(用於新項目的默認值)。如果是,請將其更改爲.NET 4 Framework

如果這也失敗了...您是否下載並安裝瞭解算器?

相關問題