Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error with SqlEntityConnection TP under VS 2015 RC and F# 3.1 #492

Closed
toburger opened this issue Jun 9, 2015 · 5 comments
Closed
Labels
Milestone

Comments

@toburger
Copy link

toburger commented Jun 9, 2015

When I use the SqlEntityConnection Type Provider with Visual Studio 2015 RC (Visual FSharp 4.0 Preview 06-03-2015) I get a runtime error when I use a different Target Runtime than 4.0.

When running the project with 4.0 everything works as expected, but when I switch the Target Runtime to 3.1 I get a runtime error:

System.IO.FileNotFoundException was unhandled
Message: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Die Datei oder Assembly "tmp7234, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

Visual Studio 2013 with Target Runtime 3.1 doesn't crash (which uses v3.1\fsc.exe).

@latkin
Copy link
Contributor

latkin commented Jun 9, 2015

Hi @toburger - I can't repro the issue given the current description. My simple SQL entity app works fine targeting 3.1 from 4.0 Some further questions for you:

  • Can you share any of the following with us? If not here on GH, then privately at fsbugs@microsoft.com.
    • Repro project/solution/source
    • Resulting binaries
  • Is the problem new with the latest F# 4.0 preview? i.e. do you know if it worked ok with an earlier F# 4.0 build?

@latkin
Copy link
Contributor

latkin commented Jun 15, 2015

Someone else reported this internally, as well, and was able to share full repro. I think I know the root cause now.

Query expressions get compiled into F# code quotations, and those get serialized in the resulting assembly. In this case the quotations contain a bogus reference to the temp assemblies used behind the scenes within the SQL type provider. They should reference the local assembly (where temp asms get statically linked), but for some reason in this cross-version scenario they are still pointing at the phantom temp assembly.

Workarounds:

  • Reference FSharp.Core 4.4.0.0
  • (Hack, but effective) Manually redirect the tmpXYZ assembly resolution back to the local assembly:
open System
open System.Reflection

AppDomain.CurrentDomain.add_AssemblyResolve(fun _ evtArgs ->
    // might want to make this a bit more robust
    if evtArgs.Name.StartsWith("tmp") then Assembly.GetExecutingAssembly()
    else null
)

@latkin
Copy link
Contributor

latkin commented Jun 15, 2015

Culprit is here - this should be a call to ConvILTypeRefUnadjusted. Looks like simple oversight with refactoring to new quotation references format, in 640db00.

/cc @dsyme

@dsyme
Copy link
Contributor

dsyme commented Jun 16, 2015

Wow good catch

@dsyme
Copy link
Contributor

dsyme commented Jun 16, 2015

@latkin - agreed that should be a call to ConvILTypeRefUnadjusted

latkin added a commit to latkin/visualfsharp that referenced this issue Jun 18, 2015
latkin added a commit to latkin/visualfsharp that referenced this issue Jun 18, 2015
@latkin latkin added this to the VS 2015 milestone Jun 18, 2015
@latkin latkin closed this as completed in dd8252e Jun 19, 2015
@latkin latkin added the fixed label Jun 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants