Closed GoogleCodeExporter closed 9 years ago
Hi Ryan!
Could this be like Joel's question and self answer at
http://stackoverflow.com/a/7828882/236255 (i.e. the hard reference is outside
of unquote)? Perhaps not, since you are receiving the error in FSI...
(BTW - I am guessing you are actually using the latest version of Unquote which
is 2.1.0 since there is no 2.4.1?)
Original comment by stephen....@gmail.com
on 26 Mar 2012 at 12:15
Ignore my previous comment: Joel's scenario was different. He actually wanted
to use Unquote in a project targeting .NET 4.0 (rather than 4.5, which is what
you want, I believe).
Original comment by stephen....@gmail.com
on 21 Apr 2012 at 6:31
I've investigated this issue using VS11 on Windows 7. I am seeing different
errors than you are with VS11 on Windows 8, but they may well be due to the
same issue just manifesting differently on different OSes. I believe this is
due to an F# forward compatibility bug. I filed the following report with the
attached demonstration solution with fsbugs:
I believe I have found a forward compatibility issue with
Microsoft.FSharp.Quotations.ExprShape.RebuildShapeCombination, which is
demonstrated by the attached solution.
My installation:
Windows 7, 64bit
Visual Studio 11 beta Ultimate, fully updated (Version 11.0.50323.1 QRLEB)
Demonstration solution (NetCompare) contains two projects:
Net40
Class library
Targets .NET 4.0
References FSharp.Core 4.0
Contains module Net40.Module40 with a single function rebuild which makes a
simple call to RebuildShapeCombination
Net45
Console application
Targets .NET 4.5
References FSharp.Core 4.3
References Net40 project
Contains file Program.fs which makes a call to Net40.Module40.rebuild
Outcome running the solution with Net45 as Startup Project: crashes on rebuild
call with the following exception detail:
System.MissingMethodException was unhandled
Message: Method not found: 'Microsoft.FSharp.Quotations.FSharpExpr
Net40.Module40.rebuild(Microsoft.FSharp.Quotations.FSharpExpr)'.
Other info:
Loading the Net40 dll in the F# 3.0 Interactive also results in a crash (which
looks insightful):
> #r @"C:\Users\Stephen\Documents\Visual Studio
11\Projects\NetCompare\Net40\bin\Debug\Net40.dll";;
--> Referenced 'C:\Users\Stephen\Documents\Visual Studio
11\Projects\NetCompare\Net40\bin\Debug\Net40.dll'
> Net40.Module40.rebuild <@ true @>;;
System.InvalidCastException: [A]CombTerm cannot be cast to [B]CombTerm. Type A
originates from 'FSharp.Core, Version=4.3.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location
'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\FSharp.Core\v4.0_4.3.0.0__b03f5f7f11
d50a3a\FSharp.Core.dll'. Type B originates from 'FSharp.Core, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at
location
'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\FSharp.Core\v4.0_4.0.0.0__b03f5f7f11
d50a3a\FSharp.Core.dll'.
at Microsoft.FSharp.Quotations.ExprShapeModule.loop@1790-39(FSharpExpr expr)
at Microsoft.FSharp.Quotations.ExprShapeModule.ShapePattern(FSharpExpr input)
at Net40.Module40.rebuild(FSharpExpr expr) in C:\Users\Stephen\Documents\Visual Studio 11\Projects\NetCompare\Net40\Module40.fs:line 8
at <StartupCode$FSI_0002>.$FSI_0002.main@()
Stopped due to error
Thoughts:
This looks like an F# 3.0 bug to me,
Microsoft.FSharp.Quotations.ExprShape.RebuildShapeCombination is a fairly
common FSharp.Core function I would expect to be forward compatible from F# 2.0
to 3.0.
Impact:
Unquote 2.1.1, which targets F# 2.0 / .NET 4.0 breaks when trying to use it
from an F# 3.0 / .NET 4.5 project. I am not aware of a workaround other than to
make a special build of Unquote targeting F# 3.0 / .NET 4.5, which is
undesirable at this time.
Original comment by stephen....@gmail.com
on 21 Apr 2012 at 6:36
Attachments:
The response from fsbugs is that this is indeed a known issue in VS11beta and
will be fixed by the final release.
The solution is to use a binding redirect from FSharp.Core 4.0.0.0 to 4.3.0.0.
In an F# library or application project, that means adding / editing an
App.config file to be like the one attached. In the F# 3.0 Interactive, that
means editing FSI's config file in the same way (Fsi.exe.config, which is
located at C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0 on my
64bit machine).
Original comment by stephen....@gmail.com
on 22 Apr 2012 at 3:19
Attachments:
Just ran in to this exact problem. The thread here suggests this would be
fixed in the final VS2012 release. I am running the release version, but still
have the issue. Do you know if it was fixed by MS as suggested here? I am
concerned that my "upgrade" from the RC to release is bad.
Original comment by ben.tayl...@gmail.com
on 8 Nov 2012 at 9:59
Hi Ben, I do not specifically know if the problem actually got fixed in the
final VS2012 release (I'm still using VS2010 myself), but it seems like there
is a good chance that it was and your "upgrade" from the RC is the culprit.
Apologies for redirecting you, but I think you might get better help asking in
the Visual F# General Forum,
http://social.msdn.microsoft.com/Forums/en-US/fsharpgeneral/threads , or
somewhere else more generally related to F# and Visual Studio.
In the meantime, I trust the manual binding redirect solution should work for
you with Unquote.
Original comment by stephen....@gmail.com
on 8 Nov 2012 at 12:39
I suspect the issue in the final VS2012 release was not fixed as I'm getting
the same issue using VS2012 on a clean install.
A workaround for the binding redirect which I took from FsUnit and use on Foq
is to add a small powershell script to the Nuget install to force the addition
of a BindingRedirect, e.g.
https://foq.codeplex.com/SourceControl/latest#Nuget/tools/install.ps1
Original comment by ptrelf...@googlemail.com
on 19 Jul 2013 at 10:46
Original issue reported on code.google.com by
ryan.ri...@panesofglass.org
on 26 Mar 2012 at 4:42