我有一个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()
的任何事情。任何有关可能导致这种情况的见解都将非常感激。
答案 0 :(得分:3)
每当方法签名在程序集之间不匹配或运行MissingMethodException
时,依赖关系之间的版本可能不匹配,这会更新您的NuGet包解决。
ServiceStack库与相同的版本号一起以锁定步骤部署,因此您可以通过比较程序集版本信息来判断dll是否是相同的版本。