Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法加载类型';System.Runtime.Remoting.Messaging.CallContext';呼叫Mongo';.NET内核上的s C#驱动程序_C#_Mongodb_Asp.net Core_.net Core_Mongodb .net Driver - Fatal编程技术网

无法加载类型';System.Runtime.Remoting.Messaging.CallContext';呼叫Mongo';.NET内核上的s C#驱动程序

无法加载类型';System.Runtime.Remoting.Messaging.CallContext';呼叫Mongo';.NET内核上的s C#驱动程序,c#,mongodb,asp.net-core,.net-core,mongodb-.net-driver,C#,Mongodb,Asp.net Core,.net Core,Mongodb .net Driver,我正在将我的web应用程序从ASP.NET MVC的.NET Framework版本升级到ASP.NET Core。我已经解决了所有的C#和Razor构建错误,现在我正试图第一次运行该应用程序。当我给MongoDB的C#驱动程序打电话时: It错误: System.TypeLoadException HResult=0x80131522消息=无法加载 从程序集中键入“System.Runtime.Remoting.Messaging.CallContext” 'mscorlib,版本=4.0.0

我正在将我的web应用程序从ASP.NET MVC的.NET Framework版本升级到ASP.NET Core。我已经解决了所有的C#和Razor构建错误,现在我正试图第一次运行该应用程序。当我给MongoDB的C#驱动程序打电话时:

It错误:

System.TypeLoadException HResult=0x80131522消息=无法加载 从程序集中键入“System.Runtime.Remoting.Messaging.CallContext” 'mscorlib,版本=4.0.0.0,区域性=中性, PublicKeyToken=b77a5c561934e089'。Source=MongoDB.Driver.Core
StackTrace:在 MongoDB.Driver.Core.Events.EventContext.AsyncLocal
1.get_Value()位于
MongoDB.Driver.Core.Events.EventContext.BeginOperation(可为null
操作ID)在
MongoDB.Driver.Core.Operations.findcommandooperation
1.Execute(IReadBinding
绑定,取消令牌(取消令牌)位于
MongoDB.Driver.Core.Operations.FindOperation
1.Execute(IReadBinding 绑定,取消令牌(取消令牌)位于 MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding 绑定,IReadOperation
1操作,CancellationToken
取消令牌)在
MongoDB.Driver.MongoCollectionImpl
1.ExecuteReadOperation[TResult](IClientSessionHandle 会话,IReadOperation
1操作,ReadPreference ReadPreference,
取消令牌(取消令牌)位于
MongoDB.Driver.MongoCollectionImpl
1.ExecuteReadOperation[TResult](IClientSessionHandle 会话,IReadOperation
1操作,取消令牌
取消令牌)在
MongoDB.Driver.MongoCollectionImpl
1.FindSync[tproject](IClientSessionHandle) 会话,筛选器定义
1筛选器,查找选项
2选项, 取消令牌(取消令牌)位于 MongoDB.Driver.MongoCollectionImpl
1.c\u显示类41\u 0
1.b\u 0(IClientSessionHandle (会议)在 MongoDB.Driver.MongoCollectionImpl
1.使用implicitsession[TResult](Func
2 func,CancellationToken CancellationToken)位于 MongoDB.Driver.MongoCollectionImpl
1.FindSync[tproject](FilterDefinition
1 过滤器,FindOptions
2选项,CancellationToken CancellationToken)
在MongoDB.Driver.FindFluent上
2.ToCursor(取消令牌 取消令牌)在 MongoDB.Driver.IAsyncCursorSourceExtensions.FirstOrDefault[TDocument](IAsyncCursorSource
1
源,CancellationToken CancellationToken)位于
MongoDB.Driver.IFindFluentExtensions.FirstOrDefault[t文档,t项目](IFindFluent
2 查找,CancellationToken CancellationToken)位于 Housters.Data.DataAccess.AnalyticsData.Find(平台、, 日期时间(日期) C:\Housters\Data\DataAccess\Common\AnalyticsData.cs:22行 Housters.Business.Services.Common.AnalyticsService.Get(平台) 平台,日期时间(日期) C:\Housters\Business\Services\Common\AnalyticsService.cs:at第31行 Housters.Business.Services.Common.AnalyticsService.Log(平台) 平台,字符串设备ID,AnalyticsEventType,布尔型 仅在中指定(已签名) C:\Housters\Business\Services\Common\AnalyticsService.cs:第19行 中的Housters.Web.Controllers.HomeController.Index() C:\Housters\Web\Controllers\HomeController.cs:at的第8行 Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(对象 目标,对象[]参数)位于 Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper 映射器,ObjectMethodExecutor,对象控制器,对象[] (a)在 Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d_u12.MoveNext()

我很困惑到底发生了什么,因为MongoDB支持.NET Core,而System.Runtime.Remoting.Messaging.CallContext是一个.NET Framework方法,.NET Core不支持它。我看到了OP面临的问题,但是他的问题是他没有使用最新的MongoDB C#驱动程序。我正在.NET标准(2.0.3)类库中使用最新的驱动程序2.8.0


Nupkg本质上是一个zip文件,包含多个版本的DLL和一些元数据

对于Mongo驱动程序,有两个目标环境的DLL

  • .NET Framework 4.5.2
  • .NET标准1.5
安装NuGet软件包时,将选择与项目匹配的dll。我假设您仍然在引用.NET framework DLL,尽管使用了支持.NET标准的NuGet包

尝试重新安装您的NuGet软件包。
验证您的bin中用于匹配.NET标准版本的DLL。

您是否尝试过
MongoDb.Driver 2.9.0-beta1
您的“数据”项目是一个.NET标准(2.0.3)类库?你的网络项目怎么样?
public static Analytics Find(Enums.Platform platform, DateTime date) {
            var builder = Filter;
            var filters = builder.Eq("Platform", platform) & builder.Eq("Date", date);
            return Collection().Find(filters).FirstOrDefault();// Exception thrown here.
        }