【问题标题】:What is the alternative for AppDomain.CurrentDomain.SetupInformation.PrivateBinPath in .netstandard 2.0.netstandard 2.0 中 AppDomain.CurrentDomain.SetupInformation.PrivateBinPath 的替代方法是什么
【发布时间】:2019-04-01 14:41:43
【问题描述】:

.netstandard 2.0 中 AppDomain.CurrentDomain.SetupInformation.PrivateBinPath 的替代方法是什么

【问题讨论】:

  • 这具体返回什么,即你想模仿什么。您是否尝试过任何替代方案,或在网上找到任何可能有助于缩小范围的资源

标签: .net .net-4.5 c#-2.0 .net-standard-2.0


【解决方案1】:

看来IHostingEnvironment 可能是您正在寻找的,文档指南在这里:https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.ihostingenvironment?view=aspnetcore-2.2

【讨论】:

  • Hi Mark,感谢您的回答,这是应用程序域配置信息。我知道这与 AssemblyLoadContext 类有关,但我找不到与我要求的相同的请求
  • 我认为您的要求可能有点不清楚,您可能需要举例说明您要模仿的内容,谢谢!
【解决方案2】:

其实我是在寻找包含代码的程序集的路径:

我发现了这个功能,我认为可以满足我的需求:

    public static string AssemblyDirectory
    {
        get
        {
            string codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri = new UriBuilder(codeBase);
            string path = Uri.UnescapeDataString(uri.Path);
            return Path.GetDirectoryName(path);
        }
    }

【讨论】:

    猜你喜欢
    • 2012-12-27
    • 1970-01-01
    • 2018-04-13
    • 1970-01-01
    • 2022-11-13
    • 2015-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多