代码之家  ›  专栏  ›  技术社区  ›  JDR Jake Ginnivan

C#:找到PresentationCore.dll(和其他组件)在GAC中

  •  0
  • JDR Jake Ginnivan  · 技术社区  · 7 年前

    我需要引用一个 CSharpCodeProvider 通过电话 ReferencedAssemblies.Add .

    ReferencedAssemblies.Add("System.dll") .

    PresentationCore.dll 是其中之一,其中需要到程序集的完整路径-我可能不一定在目标计算机上知道。

    问题:

    理想情况下,解决方案不仅适用于 ,还有其他程序集,例如 PresentationFramework.dll System.Xaml.dll System.Windows.Forms .

    • This solution
    • 实施 this Windows API 可能有用;但我不知道如何-或者它是否能帮助解决上述问题
    • This C++问题是指GAC的发现,而不是如何获取实际的文件路径。
    1 回复  |  直到 5 年前
        1
  •  0
  •   thehennyy    7 年前

    typeof([TypeKnownToBeInTheDesiredAssembly]).Assembly.CodeBase

    例如,找到系统.Xml.dll:

    string codeBase = typeof(System.Xml.XmlDocument).Assembly.CodeBase;
    UriBuilder uri = new UriBuilder(codeBase);
    string path = Uri.UnescapeDataString(uri.Path);
    Console.WriteLine(path);
    

    [ref]

    在我的系统上:

    推荐文章