fsprojects / FSharp.Interop.Dynamic

DLR interop for F# -- works like dynamic keyword in C#
https://fsprojects.github.io/FSharp.Interop.Dynamic/
Apache License 2.0
95 stars 14 forks source link

can't load newer version of fsharp.core #25

Closed WillEhrendreich closed 2 years ago

WillEhrendreich commented 2 years ago

Description

image

image

I'm currently writing a plugin for Autodesk Inventor, and it uses Com, so thats why i thought this library might be a perfect way to interact with it's api, especially if I use it from FSI.exe. the trouble comes when i try to use the library, it complains of not being able to find fsharp.core 4.4.1.0.

well, yeah, i don't have that one, I have 4.6.2 being referenced in my fsproj

but is there any reason that the newer one would be incompatible?

If not, how do i convince it to use 4.6.2?

Repro steps

I think all it would take is to have a new project, make sure to grab 4.6.2 from nuget, then try to do.. something.. ? (noob alert, sorry)

To be honest I'm not sure, the added wrinkle in providing any good repro steps is that not everyone has Autodesk Inventor, and fewer still try to write a plugin in fSharp if they do have inventor. I honestly don't know anyone else in the Inventor community that uses fsharp for anything.. which makes asking for help a hail mary every time.

Expected behavior

I expected that since 4.6.2 is newer, it wouldn't break by trying to find the exact version?

Actual behavior

Inventor throws an exception that it cannot find the dll, and that the one it found has a wrong minor version.

Known workarounds

Not sure, because I really can't go back to 4.4.* because another part of my project (elmish.wpf) depends on that exact version, unfortunately.

Related information

jbtule commented 2 years ago

No reason a newer one would be incompatible.

Sounds like you are using .net48. Look into binding redirects.

https://stackoverflow.com/a/43366172

TysonMN commented 2 years ago

Known workarounds

Not sure, because I really can't go back to 4.4.* because another part of my project (elmish.wpf) depends on that exact version, unfortunately.

Version 4.0.0-beta-45 of Elmish.WPF does not depend on an exact version of FSharp.Core. It depends on a version that is at least 6.0.5.

TysonMN commented 2 years ago

Oh, but that is the latest version, so practically that is currently true.

https://www.nuget.org/packages/FSharp.Core/

dsyme commented 2 years ago

This library is not large. Have you considered just including it by source?

I'm assuming the problem is that autodesk isn't giving a way to apply binding redirects to plugins, or else your build is not set up to generate and deploy the necessary binding redirects file. If the latter you might be able to solve the problem by turning on AutoGenerateBindingRedirects

WillEhrendreich commented 2 years ago

Hey, I finally found a way to do it, for anyone interested, one has to change the inventor.exe.config file found in (by default) c:/program files/Autodesk/inventor {year here, mine's 2022}/bin/

I put this in it

      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.5.9.9" newVersion="4.6.0.0" />
      </dependentAssembly>

seems to be working, so.. i guess i will go with it! haha. I believe i tried the fsharp core 6 version, and elmish still gave me an error like the one described in the other issue, so I'm a bit gun shy to try and mess with it unless there's a compelling reason to.

@dsyme thanks for trying to help, and even more than that, THANK YOU FOR FSHARP!!!! I ABSOLUTELY LOVE IT! (ok, I know other people worked tons on it too, but you get a giant portion of the blame for me being utterly spoiled by it, and ruined for any other language, lol.)

I didn't consider just including the source, that's a good idea.. if I have to I will do that, if this binding redirects thing is an issue in the future, which it might be, because, I'm not sure if I'm going to be able to do the redirecting on everyone else's machine too, it's a bit of a hacky solution to have to mess with files in multiple directories on the users' machines, and there's no way I'm asking each individual in my company who wants to use this to manually edit config files.. I dunno.. that is a bridge I'll cross another time.. thanks all for your help!