Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Searching The GAC

Tags:

c#

.net

f#

gac

I'm trying to use the FSharp PowerPack for the ArgParser library, but running into some serious issues on my machine where it seems to be loading the wrong version of FSharp.Core.dll from the GAC that then causes the load of ArgParser to fail. Ideally I would get the issue with that fixed (since it works on my coworker's computers) but I've tried all sorts of combinations of uninstalling and reinstalling the FSharp binaries from the system to no avail.

As I don't really like the fact that I cannot just drop the DLLs that are known to be the correct ones in the executable directory because of the GAC, if there is any way to just disable searching in the GAC I will happily do that.

I know that that solution would be a bit of a hack, but right now I just need to get this to load and work and I'll try anything.

EDIT

Some more info. Here's the load output for the project.

'PowerPackTest.exe' (Managed (v4.0.30319)): Loaded 'C:\WINNT\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'PowerPackTest.exe' (Managed (v4.0.30319)): Loaded 'C:\Projects\PowerPackTest\PowerPackTest\bin\Debug\PowerPackTest.exe', Symbols loaded.
'PowerPackTest.exe' (Managed (v4.0.30319)): Loaded 'C:\WINNT\Microsoft.Net\assembly\GAC_MSIL\FSharp.Core\v4.0_4.0.0.0__b03f5f7f11d50a3a\FSharp.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'PowerPackTest.exe' (Managed (v4.0.30319)): Loaded 'C:\WINNT\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'PowerPackTest.exe' (Managed (v4.0.30319)): Loaded 'C:\WINNT\assembly\GAC_MSIL\FSharp.PowerPack\2.0.0.0__a19089b1c74d0809\FSharp.PowerPack.dll'
'PowerPackTest.exe' (Managed (v4.0.30319)): Loaded 'C:\WINNT\assembly\GAC_MSIL\FSharp.Core\2.0.0.0__b03f5f7f11d50a3a\FSharp.Core.dll'

As you can see, it loads FSharp.Core v4 first, but then loads v2 over it at the last second. This does not happen on my coworker's machines.

like image 607
Adam Haile Avatar asked Mar 10 '11 16:03

Adam Haile


1 Answers

The pre-built PowerPack binaries are compiled against CLR v2, and they reference FSharp.Core v2 as well. That's probably what's causing this problem. I don't really understand why a .NET 4 version of the PowerPack isn't offered as a download (or in NuGet!) but you can work around this two ways:

You can set up an assembly binding redirect, but I don't know if this would work for fsi.exe.

Or you can download the source code to the F# PowerPack and compile your own .NET 4 version. It's pretty easy.

like image 102
Joel Mueller Avatar answered Sep 20 '22 02:09

Joel Mueller