Use Microsoft Solver Foundation in C#
Asked Answered
F

4

5

I'm trying to use Microsoft Solver Foundation in my C# application in VS2010 Ultimate. I've installed MSF (64 bit version) and as far as I understand I should be able to use the services after declaring:

using Microsoft.SolverFoundation;

However, I get the error "The type or namespace name 'SolverFoundation' does not exist in the namespace 'Microsoft'".

I see that there's Microsoft.Solver.Foundation.dll located in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0

Initially I thought the 64 bit version might be the problem so I uninstalled and switched to the 32 bit version. But no success either.

How can I integrate MSF into my C# application?

Frans answered 13/7, 2011 at 13:21 Comment(0)
F
6

I've already tried adding the references before but it wouldn't work. Now I've noticed something in the warnings (which I probably didn't see before):

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

I fixed this by setting Application Properties -> Application -> Target Framework from ".Net Framework 4 Client Profile" to ".Net Framework 4".

Frans answered 14/7, 2011 at 7:37 Comment(1)
Correct, you need to have your project target the full .NET 4 framework, it doesn't work with the Client Profile.Sportsmanship
K
6

I'm trying to use Microsoft Solver Foundation in my C# application in VS2010 Ultimate. I've installed MSF (64 bit version) and as far as I understand I should be able to use the services after declaring:

using Microsoft.SolverFoundation;

How can I integrate MSF into my C# application?

At no point did you mention that you added a reference to this library to your project, and the behavior you are describing is consistent with not having added a reference. Therefore, you also need to add a reference to this library to your project.

Krems answered 13/7, 2011 at 13:22 Comment(0)
F
6

I've already tried adding the references before but it wouldn't work. Now I've noticed something in the warnings (which I probably didn't see before):

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

I fixed this by setting Application Properties -> Application -> Target Framework from ".Net Framework 4 Client Profile" to ".Net Framework 4".

Frans answered 14/7, 2011 at 7:37 Comment(1)
Correct, you need to have your project target the full .NET 4 framework, it doesn't work with the Client Profile.Sportsmanship
E
1

Does "Microsoft Solver Foundation" show up when you go to Add Reference...?

If it does not perhaps you are not using the correct framework, try Project -> Properties.. -> Compile -> Advanced Compile Options... and certify you are NOT using .NET 4 Framework Client Profile (uses to be default for new projects). If it is, change it to .NET 4 Framework.

If that also fails... have you downloaded and installed the solver?

Enchase answered 8/9, 2012 at 19:55 Comment(0)
H
0

You need to add a reference to that DLL you found to your project.

Hillel answered 13/7, 2011 at 13:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.