简体   繁体   English

禁用搜索GAC

[英]Disable Searching The 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. 我正在尝试将FSharp PowerPack用于ArgParser库,但在我的机器上遇到一些严重的问题,它似乎从GAC加载错误版本的FSharp.Core.dll然后导致ArgParser的加载失败。 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. 理想情况下,我会得到修复的问题(因为它适用于我的同事的计算机),但我尝试了从系统卸载和重新安装FSharp二进制文件的各种组合,但无济于事。

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. 因为我不喜欢我不能因为GAC而丢弃已知在可执行文件目录中的正确DLL的事实,如果有任何方法只能在GAC中禁用搜索,我将很乐意这样做。

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. 如您所见,它首先加载FSharp.Core v4,但在最后一秒加载v2。 This does not happen on my coworker's machines. 这不会发生在我的同事的机器上。

The pre-built PowerPack binaries are compiled against CLR v2, and they reference FSharp.Core v2 as well. 预构建的PowerPack二进制文件是针对CLR v2编译的,它们也引用了FSharp.Core v2。 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: 我真的不明白为什么不提供PowerPack的.NET 4版本作为下载(或在NuGet!中),但你可以解决这两种方式:

You can set up an assembly binding redirect , but I don't know if this would work for fsi.exe . 您可以设置程序集绑定重定向 ,但我不知道这是否适用于fsi.exe

Or you can download the source code to the F# PowerPack and compile your own .NET 4 version. 或者您可以将源代码下载到F#PowerPack并编译自己的.NET 4版本。 It's pretty easy. 这很容易。

The GAC always wins - this is a security feature. GAC总是赢 - 这是一个安全功能。 If you have a different version of FSharp.Core, why don't you drop that in the GAC too and either use a redirect binding in your app.config to force loading of the newer version, or rebuild your app (may not be possible) against the new version? 如果您有不同版本的FSharp.Core,为什么不将它放在GAC中,并在app.config中使用重定向绑定来强制加载较新版本,或重建您的应用程序(可能无法实现) )对新版本?

-Oisin -Oisin

I just looked at a .net 4.0 project where i am using the ArgParser, i am referencing the FSharp.Core and FSharp.Powerpack, as well as in the app.config i have the redirect setup: 我只是看了一个.net 4.0项目,我正在使用ArgParser,我正在引用FSharp.Core和FSharp.Powerpack,以及在app.config中我有重定向设置:

    <startup useLegacyV2RuntimeActivationPolicy="true">
       <supportedRuntime version="v4.0"/>
    </startup>

hth 心连心

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM