Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Compatibility .Net 4.0 and .Net 4.5. Could not load file or Assembly 'FSharp.Core, Version=4.3.1.0.'

I want to use the library Math.NET Symbolics in the F# project. But when I run simple code:

open MathNet.Symbolics
open MathNet.Symbolics.Operators

...

let expr = Infix.parseOrThrow("sin(x) * y")
let symbols = Map.ofList [ "x", Real 2.0; "y", Real 3.0 ]
let res = Evaluate.evaluate symbols expr

I have:

Could not load file or Assembly ' FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" or one of the dependent components. The system cannot find the file specified.

I created a topic in the forum Math.NET

During the discussion, I thought it was impossible, because I only have .Net 4.5 and VS2012 (therefore I can't use F#3.1).

But I can't understand, if everything works in .Net 4.0, why I can not normal use in .Net 4.5. What about compatibility version?

Question: is it even possible? And, if possible, how?

Edit:

When app.config has:

<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
<bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="4.3.0.0" />

This code works fine:

let symbols = Map.ofList [ "x", Real 2.0; "y", Real 3.0 ]
let x = symbol "x"
let y = symbol "y"
let res = Evaluate.evaluate symbols (sin(x) * y) 

But I need to use a parser for mathematical expressions. Therefore, this option does not suit me.

Update:

Answer:

After an unsuccessful compile Visual Studio was changed reference to the FSharp.Core from package folder on a standard FSharp.Core 4.3.0.0. When I set the property "Copy Local" = "true" - problem was solved.

Now code

let expr = Infix.parseOrThrow("sin(x) * y")
let symbols = Map.ofList [ "x", Real 2.0; "y", Real 3.0 ]
let res = Evaluate.evaluate symbols expr

gives another exception:

System.TypeInitializationException: The type initializer for '<StartupCode$MathNet-Symbolics>.$Infix'
 threw an exception. ---> System.Security.VerificationException: Operation could destabilize the runtime

I was looking for a mistake where it was not. The problem is not dependence. Because code without using FParces worked!

On the page for the package is written as follows:

"This package uses the basic "low-trust" configuration of FParsec, which does not use any unverifiable code and is optimized for maximum portability. If you need to parse very large files or if you employ FParsec for performance-critical jobs, consider using the alternate "Big Data Edition" NuGet package (see nuget.org/packages/fparsec-big-data-edition)."

So, I changed FParsec on FParsec (Big Data Edition) and everything works!

P.S. My attempts to change the binding redirect did not make sense =) just write:

<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />

Answer*

Draft saved
Draft discarded
Cancel
5
  • Thanks. Unfortunately, I have no way to update Visual Studio. I found the answer to my question, without recompiling Math.Net. Commented Jan 7, 2016 at 16:33
  • Since it costs nothing to install a newer version of F# into Visual Studio, and it costs nothing to download the Community Edition of VS 2015, I have to assume it's your employer preventing you from using the tools you need to do your job. That doesn't reflect well on your employer. Commented Jan 7, 2016 at 19:45
  • At the moment, programming for me is only a hobby . I don't have the ability to update Windows7, which will allow to install at least VS2013. But I plan to do this at the end of the month. Although, of course, the update creates some additional difficulties. Commented Jan 7, 2016 at 20:58
  • @FoggyFinder - Why would you need to update Windows 7? Is it because VS 2015 requries Win7 SP1? That service pack is more than 5 years old... Commented Jan 7, 2016 at 22:40
  • 1
    I have quite an old laptop. And I'm afraid that if I change OS something goes wrong. I can't risk it now. Commented Jan 7, 2016 at 23:38

lang-ml

AltStyle によって変換されたページ (->オリジナル) /