2013-03-06 56 views
1

我很難解決此問題。我仍然向ServiceStack自我介紹,同時嘗試向我的Web應用程序添加MySql數據庫(這可能與錯誤完全無關),我遇到了阻止我的應用程序運行的錯誤。我解開了很多步驟,但無法回到正常工作的時候。任何幫助將不勝感激。無法修復「/'應用程序中的服務器錯誤」ServiceStack

錯誤:

Method 'get_IsLocal' in type 
ServiceStack.WebHost.Endpoints.Extensions.HttpRequestWrapper' from assembly 
'ServiceStack, Version=3.9.37.0, Culture=neutral, 
PublicKeyToken=null' does not have an implementation. 

源錯誤:

An unhandled exception was generated during the execution of the current 
web request. Information regarding the origin and location of the exception 
can be identified using the exception stack trace below. 

堆棧跟蹤:

[TypeLoadException: Method 'get_IsLocal' in type 
'ServiceStack.WebHost.Endpoints.Extensions.HttpRequestWrapper' from assembly 
'ServiceStack, Version=3.9.37.0, Culture=neutral, PublicKeyToken=null' does 
not have an implementation.] 
ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory.GetHandler 
(HttpContext context, String requestType, String url, String pathTranslated) +0 
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication. 
IExecutionStep.Execute() +346 
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& 
completedSynchronously) +155 

我的代碼:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.SessionState; 
using ServiceStack.Configuration; 
using ServiceStack.OrmLite; 
using ServiceStack.OrmLite.MySql; 
using ServiceStack.ServiceInterface; 
using ServiceStack.ServiceInterface.Auth; 
using ServiceStack.ServiceInterface.Validation; 
using ServiceStack.FluentValidation; 
using ServiceStack.ServiceInterface.ServiceModel; 
using ServiceStack.WebHost.Endpoints; 
using ServiceStack.ServiceHost; 
using ServiceStack.Common.Utils; 
using ServiceStack.DataAnnotations; 
using ServiceStack.Common; 

namespace SampleHello2 
{ 
    public class CustomCredentialsAuthProvider : CredentialsAuthProvider 
    { 
     public override bool TryAuthenticate(IServiceBase authService, string userName, string password) 
     { 
      //Add here your custom auth logic (database calls etc) 
      return (userName == "Ian" && password == "pass"); 
     } 

     public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary<string, string> authInfo) 
     { 
      //Fill the IAuthSession with data which you want to retrieve in the app eg: 
      session.FirstName = "Ian Mc Garry"; 
      //... 

      //Important: You need to save the session! 
      authService.SaveSession(session, SessionExpiry); 
     } 
    } 


    public class Global : System.Web.HttpApplication 
    { 
     public class HelloAppHost : AppHostBase 
     { 
      //Tell Service Stack the name of your application and where to find your web services 
      public HelloAppHost() : base("Hello Web Services", typeof(HelloService).Assembly) { } 

      public override void Configure(Funq.Container container) 
      { 
       //Enable Features 
       Plugins.Add(new ValidationFeature()); 
       Plugins.Add(new AuthFeature(() => new AuthUserSession(), 
        new IAuthProvider[] { 
         new CustomCredentialsAuthProvider(), //HTML Form post of UserName/Password credentials 
        } 
       )); 

       //register any dependencies your services use, e.g: 
       container.RegisterValidators(typeof(HelloValidator).Assembly); 

       //Database 
       //string conn = "Server=host;Port=3306;Database=db;UserId=user;Password=pass;"; 
       //container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(conn, MySqlDialectProvider.Instance)); 
      } 
     } 

     //Initialize your application singleton 
     protected void Application_Start(object sender, EventArgs e) 
     { 
      new HelloAppHost().Init(); 
     } 
    } 

} 

再次,任何幫助將不勝感激。問題可能很清楚,但我解決不了。此外,我自己也沒有足夠的經驗來了解問題(錯誤/堆棧跟蹤)。我看到它指的是我正在使用的包裹ServiceStack.WebHost.Endpoints;,但這是我能夠獲得的。

很多謝謝。

回答

4

這聽起來像你有髒.dll。確保你更新所有NuGet包,如果問題仍然存在,請清理NuGet /packages文件夾,然後重試。

注意最新版本(截至2013年3月6日)MySql OrmLite包是v3.9.39。

+0

謝謝你。此刻離開我的電腦,但我會讓你知道它是如何消失的。 – gimg1 2013-03-07 17:19:29

+1

只是更新包修復了一切。非常感謝支持。 – gimg1 2013-03-07 17:29:52

相關問題