禁用搜索 GAC

发布于 2024-10-21 17:44:04 字数 1616 浏览 7 评论 0原文

我正在尝试将 FSharp PowerPack 用于 ArgParser 库,但在我的计算机上遇到了一些严重问题,它似乎从 GAC 加载了错误版本的 FSharp.Core.dll,从而导致 ArgParser 加载失败。理想情况下,我会解决该问题(因为它可以在我同事的计算机上运行),但我已经尝试了从系统中卸载和重新安装 FSharp 二进制文件的各种组合,但均无济于事。

因为我真的不喜欢这样的事实,即由于 GAC,我不能直接将已知的 DLL 删除到可执行目录中,如果有任何方法可以禁用搜索GAC 我很乐意这样做。

我知道这个解决方案有点麻烦,但现在我只需要让它加载并工作,我会尝试任何事情。

编辑

更多信息。这是该项目的负载输出。

'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'

正如您所看到的,它首先加载 FSharp.Core v4,但在最后一秒加载 v2。在我同事的机器上不会发生这种情况。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

静若繁花 2024-10-28 17:44:04

预构建的 PowerPack 二进制文件是针对 CLR v2 编译的,并且它们也引用 FSharp.Core v2。这可能就是导致这个问题的原因。我真的不明白为什么 .NET 4 版本的 PowerPack 不提供下载(或在 NuGet 中!),但您可以通过两种方式解决此问题:

您可以设置 程序集绑定重定向,但我不知道这是否适用于 fsi.exe

或者,您可以将源代码下载到 F# PowerPack 并编译您自己的 .NET 4 版本。这很容易。

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.

水波映月 2024-10-28 17:44:04

GAC 总是获胜——这是一项安全功能。如果您有不同版本的 FSharp.Core,为什么不将其也放入 GAC 中,并在 app.config 中使用重定向绑定来强制加载新版本,或者重建您的应用程序(可能不可能) )反对新版本?

The GAC always wins - this is a security feature. 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?

影子是时光的心 2024-10-28 17:44:04

我刚刚查看了一个 .net 4.0 项目,其中我使用 ArgParser,我引用了 FSharp.Core 和 FSharp.Powerpack,以及在 app.config 中我有重定向设置:

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

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:

<startup useLegacyV2RuntimeActivationPolicy="true">
   <supportedRuntime version="v4.0"/>
</startup>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文