2013-03-06 57 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

相关问题