【问题标题】:Assembly not being loaded from mkbundle'd executable未从 mkbundle 的可执行文件加载程序集
【发布时间】:2014-04-25 09:43:12
【问题描述】:

我正在 mkbundling 一堆程序集,包括 ServiceStack.Text。运行 mkbundle 时,它​​告诉我它正在被嵌入:

embedding: /home/user/Verisys/build/ServiceStack.Text.dll

但是,当我尝试运行生成的可执行文件时,我得到了这个:

Unhandled exception
System.ApplicationException: RootDir '/opt/mono32/lib/mono/gac/ServiceStack.Text/4.0.0.0__e06fbc6124f57c43' for virtual path does not exist
  at ServiceStack.VirtualPath.FileSystemVirtualPathProvider.Initialize () [0x00000] in <filename unknown>:0 
  at ServiceStack.VirtualPath.FileSystemVirtualPathProvider..ctor (IAppHost appHost, System.IO.DirectoryInfo rootDirInfo) [0x00000] in <filename unknown>:0 
  at ServiceStack.VirtualPath.FileSystemVirtualPathProvider..ctor (IAppHost appHost, System.String rootDirectoryPath) [0x00000] in <filename unknown>:0 
  at ServiceStack.ServiceStackHost.Init () [0x00000] in <filename unknown>:0 
  at MyExe.OnStart (System.String[] args) [0x00000] in <filename unknown>:0 

知道为什么它尝试从 GAC 加载此程序集,而不是使用嵌入式程序集吗?

【问题讨论】:

    标签: mono servicestack gac mkbundle


    【解决方案1】:

    ServiceStack 获取WebHostPhysicalPath 的方式似乎存在错误。您可以通过在 AppHostConfigure 方法中手动指定应用程序的根目录来自行解决此问题:

    public override void Configure(Funq.Container container)
    {
        Config = new HostConfig {
            WebHostPhysicalPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
            ...
        }
    }
    

    【讨论】:

    • 这解决了它,谢谢!我自己永远也不会意识到这一点!
    • 它没有解决我的问题。我仍然有同样的问题。还有其他答案吗?
    • @DeeJay' 如果您遇到问题,请创建您自己的问题并提供您已采取的步骤以及正在发生的问题的详细信息。
    • 谢谢斯科特。我通过升级 .net 框架解决了它(我实际上不记得版本,但它是同一个 4.0 中的一个小版本)无论如何我的问题与问题中描述的相同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-14
    • 2016-06-21
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 2021-05-22
    相关资源
    最近更新 更多