ServiceStackHost.Instance已经设置好了

时间:2014-11-02 21:39:29

标签: c# mono xamarin servicestack nuget

我有一个奇怪的问题。

我已经实现了标准的服务堆栈API。

它在去年一直很完美。

上周我看到了Xamarin Studio的一些重大变化,因此决定更新我的IDE。

随着更新NuGet成为标准,所以我决定转换我的服务堆栈参考文件以使用NuGet。非常好,现在我可以点击一下来更新DLL等。

因此API现在可以在我的Windows机器上正常运行,没有问题。

问题:我们的服务器在安装了Mono的情况下运行Ubuntu。而且它不想让步。

我最初得到此错误:

System.TypeLoadException: A type load exception has occurred.
  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 API_NOTIFICATION.Global.Application_Start (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

然后我刷新页面并不断收到此错误:

System.IO.InvalidDataException: ServiceStackHost.Instance has already been set
  at ServiceStack.ServiceStackHost.Init () [0x00000] in <filename unknown>:0 
  at API_NOTIFICATION.Global.Application_Start (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

以前有人经历过这个吗?任何人都知道如何解决这个问题?

我确实看过与此类似的其他帖子。

不知道在哪里找到:

App_Start/ServiceStackFramework.cs

不知道如何删除,我无法在任何地方找到它。但谁知道,它甚至可能都不是同一个问题。

我使用标准教程来设置发布在ServiceStack网站上的API。

任何帮助将不胜感激。就像我说的那样,唯一真正改变的想法是IDE并通过NuGet更新那些ServiceStack引用。

APPHOST:

public class ResponseNotificationServiceAppHost : AppHostBase
{
    public ResponseNotificationServiceAppHost() : base("Response Notification Services", typeof(NotificationServices).Assembly)
    {
    }

    #region implemented abstract members of AppHostBase

    public override void Configure(Funq.Container container)
    {

    }

    #endregion
}

全局:

public class Global : System.Web.HttpApplication
{       
    protected void Application_Start(Object sender, EventArgs e)
    {
        new ResponseNotificationServiceAppHost().Init();
    }
}

API服务类:

public class NotificationServices : Service
{
     public PersonNotificationResponse Any(PersonNotification request) 
     {
          // Implementation Code here
     }
}

更新:

尝试删除AppHost时,API无法加载。我在Ubuntu服务器上收到以下错误:

System.NullReferenceException: Object reference not set to an instance of an object
  at ServiceStack.HttpHandlerFactory..cctor () [0x00000] in <filename unknown>:0 

1 个答案:

答案 0 :(得分:1)

看起来这是单声道框架的问题。

服务器在12.04 LTS服务器上运行2.10.5 Mono。

我在安装了Mono 3.2.6的新14.04 LST服务器上托管了API。

现在工作正常。

可能ServiceStack已更新,不再与2.10.5兼容。不确定,只能推测。

相关问题