c# - mscoree.dll 的 GetRequestedRuntimeInfo() 导致不正确的 TargetFrameworkDirectories - 如何调试?

标签 c# c++ debugging .net-3.5

我遇到了一个问题,我的 .Net 构建系统在错误的文件夹中查找其框架引用。机器上安装了.Net 4.0和Visual Studio 2010,.Net版本低于4.0的项目会出现这个问题(我的例子是.Net 3.5)。这个问题看起来像是构建问题,但深入研究后,我发现 Microsoft.Build.Tasks.v4.0.dll(在构建过程中调用)正在调用 mscoree.dll 并返回错误信息:

(反编译源) FrameworkLocationHelper。 ConstructDotNetFrameworkPathFromRuntimeInfo(字符串请求版本):

        int num1 = 264;
        int num2 = 25;
        StringBuilder pDirectory;
        StringBuilder pVersion;
        uint requestedRuntimeInfo;
        do
        {
            pDirectory = new StringBuilder(num1);
            pVersion = new StringBuilder(num2);
            uint dwDirectoryLength;
            uint dwlength;
-------->   requestedRuntimeInfo = NativeMethodsShared.GetRequestedRuntimeInfo(string.Empty, requestedVersion, string.Empty, 16U, 64U, pDirectory, num1, out dwDirectoryLength, pVersion, num2, out dwlength);
            num1 *= 2;
            num2 *= 2;
        }
        while ((int)requestedRuntimeInfo == -2147024774);
        if ((int)requestedRuntimeInfo == 0)
            return Path.Combine(((object)pDirectory).ToString(), ((object)pVersion).ToString());

问题是对 NativeMethodsShared.GetRequestedRuntimeInfo(...) 的调用,它在其他机器上返回请求的 .Net 版本(3.5、3.0 和 2.0),但在有问题的机器上每次返回 4.0,导致引用 .Net 4.0 的引用路径(这不应发生在 .Net 3.5 构建中)。不幸的是,这是对 mscoree.dll 的调用,我不知道如何调试它或找到源代码:

[DllImport("mscoree.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint GetRequestedRuntimeInfo(string pExe, string pwszVersion, string pConfigurationFile, uint startupFlags, uint runtimeInfoFlags, StringBuilder pDirectory, int dwDirectory, out uint dwDirectoryLength, StringBuilder pVersion, int cchBuffer, out uint dwlength);

供引用,其他工作机器将有这些框架目录:

目标框架目录: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\, C:\Windows\Microsoft.NET\Framework\v3.5\, C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\, C:\Windows\Microsoft.NET\Framework\v3.0\, C:\Windows\Microsoft.NET\Framework\v2.0.50727\

虽然问题机器有这些框架目录:

目标框架目录: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\, C:\Windows\Microsoft.NET\Framework\v4.0.30319\, C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\, C:\Windows\Microsoft.NET\Framework\v4.0.30319\, C:\Windows\Microsoft.NET\Framework\v4.0.30319\

此外,我已经卸载并重新安装了 .Net 2.0、3.0、3.5、4.0 和 Visual Studio 2010

最佳答案

Mscoree.dll 不是 Oracle。使用 SysInternals 的 ProcMon 实用程序找出计算机注册表的保存位置。最好将跟踪与可以快速缩小范围的机器进行比较。

关于c# - mscoree.dll 的 GetRequestedRuntimeInfo() 导致不正确的 TargetFrameworkDirectories - 如何调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6784509/

相关文章:

python - 使用调试控制台时出错 : DeprecationWarning: The `use_readline` parameter is deprecated and ignored since IPython 6. 0

c# - 如何使用azure函数应用程序读取azure blob中的内容

c# - 当使用管理包装器取消管理 C++ DLL 时,.net 是否创建任何临时 C# 文件

c++ - 对图执行边收缩

c++ - 所以,我们有 int32_t、int16_t、uint64_t 等。但是 atoi32、atoi16、atoui64 等在哪里……?

c++ - 保存调试状态以跳过长时间的计算

c# - 如何解决 'Windows Azure' 转换 ASP.NET 3.5 到 4.0 的此错误?

c# - 如何仅垂直移动无边框表格?

c++ - 使用 Winsock DLL 在简单的 TCP 回显服务器中分离消息

macos - 如何使用 Homebrew 软件构建带有调试符号的库?