ServiceStack.Text.JsConfig.With (. .)缺少方法

本文关键字:方法 Text JsConfig With ServiceStack | 更新日期: 2023-09-27 18:09:28

我有一个Asp。Net MVC应用程序,有一些错误的原因,我似乎无法追踪。我认为它们是相关的,但我对ServiceStack不够熟悉,无法确定。

对于初学者,我一直看到下面的异常抛出:

Method not found: 'ServiceStack.Text.JsConfigScope ServiceStack.Text.JsConfig.With(
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, 
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, 
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>,
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, 
System.Nullable`1<ServiceStack.Text.DateHandler>,
System.Nullable`1<ServiceStack.Text.TimeSpanHandler>,
System.Nullable`1<ServiceStack.Text.PropertyConvention>,
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>,
System.String, System.Func`2<System.Type,System.String>,
System.Func`2<System.String,System.Type>,
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>,
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>,
System.Nullable`1<Boolean>, System.Nullable`1<Boolean>,
System.Nullable`1<Int32>, ServiceStack.EmptyCtorFactoryDelegate,
System.String[])'.

这个方法实际上并没有在我自己的代码中被调用。这个错误似乎一直在ServiceStack中发生。一个例子是当尝试获取一个键入的会话时:

AppServiceBase.cs

using ServiceStack;
namespace MyWebProject.ServiceInterface
{
    public abstract class AppServiceBase : Service
    {
        public virtual UserSession UserSession
        {
            get { 
                return SessionAs<UserSession>(); // Throws an error when called
            }
        }
    }
}

这会给我一个像这样的堆栈跟踪:

[MissingMethodException: Method not found: 'ServiceStack.Text.JsConfigScope ServiceStack.Text.JsConfig.With(System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<ServiceStack.Text.DateHandler>, System.Nullable`1<ServiceStack.Text.TimeSpanHandler>, System.Nullable`1<ServiceStack.Text.PropertyConvention>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.String, System.Func`2<System.Type,System.String>, System.Func`2<System.String,System.Type>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.Nullable`1<Int32>, ServiceStack.EmptyCtorFactoryDelegate, System.String[])'.]
   ServiceStack.Redis.RedisClient.Exec(Func`2 action) +0
   ServiceStack.Redis.RedisClient.Get(String key) +241
   ServiceStack.Redis.RedisClientManagerCacheClient.Get(String key) +142
   ServiceStack.SessionExtensions.SessionAs(ICacheClient cache, IRequest httpReq, IResponse httpRes) +150
   ...Where it was called from and the rest of the stack.

这似乎发生在任何调用JsConfig.With()的地方。对于可能导致这种情况的任何见解将不胜感激。

ServiceStack.Text.JsConfig.With (. .)缺少方法

每当程序集之间的方法签名不匹配或存在运行时MissingMethodException时,很可能存在依赖项之间的版本不匹配,更新您的NuGet包应该解决。

ServiceStack库与相同的版本号一起以锁步方式部署,因此您可以通过比较汇编版本信息来判断dll是否为相同的版本。