MongOData icon indicating copy to clipboard operation
MongOData copied to clipboard

TypeInitializationException in ctor

Open object opened this issue 10 years ago • 4 comments

This is the exception that is thrown from the Mongo.Context

System.TypeInitializationException was unhandled by user code HResult=-2146233036 Message=The type initializer for 'Mongo.Context.MongoMetadata' threw an exception. Source=Mongo.Context TypeName=Mongo.Context.MongoMetadata StackTrace: at Mongo.Context.MongoMetadata..ctor(String connectionString, Metadata metadata) at Mongo.Context.MongoDataServiceBase2.<.ctor>b__1(String x) at Mongo.Context.MongoDataServiceBase2..ctor(String connectionString, MongoConfiguration mongoConfiguration) at Mongo.Context.Queryable.MongoQueryableDataService..ctor(String connectionString, MongoConfiguration mongoConfiguration) at Odata.MongoDataService..ctor() in c:\Users\dtaylor\Documents\Visual Studio 2013\Projects\Odata Service\Odata\MongoDataService.cs:line 12 at CreateOdata.MongoDataService() at System.ServiceModel.Dispatcher.InstanceProvider.GetInstance(InstanceContext instanceContext, Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.GetInstance(InstanceContext instanceContext, Message request) at System.ServiceModel.InstanceContext.GetServiceInstance(Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) InnerException: System.IO.FileNotFoundException HResult=-2147024894 Message=Could not load file or assembly 'MongoDB.Bson, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The system cannot find the file specified. Source=Mongo.Context FileName=MongoDB.Bson, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103 FusionLog==== Pre-bind state information === LOG: DisplayName = MongoDB.Bson, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103 (Fully-specified) LOG: Appbase = file:///c:/users/dtaylor/documents/visual studio 2013/Projects/Odata Service/Odata/ LOG: Initial PrivatePath = c:\users\dtaylor\documents\visual studio 2013\Projects\Odata Service\Odata\bin

Calling assembly : Mongo.Context, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. LOG: This bind starts in default load context. LOG: Using application configuration file: c:\users\dtaylor\documents\visual studio 2013\Projects\Odata Service\Odata\web.config LOG: Using host configuration file: C:\Users\dtaylor\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: MongoDB.Bson, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103 LOG: Attempting download of new URL file:///C:/Users/dtaylor/AppData/Local/Temp/Temporary ASP.NET Files/root/9b6a506e/5b857965/MongoDB.Bson.DLL. LOG: Attempting download of new URL file:///C:/Users/dtaylor/AppData/Local/Temp/Temporary ASP.NET Files/root/9b6a506e/5b857965/MongoDB.Bson/MongoDB.Bson.DLL. LOG: Attempting download of new URL file:///c:/users/dtaylor/documents/visual studio 2013/Projects/Odata Service/Odata/bin/MongoDB.Bson.DLL. LOG: Attempting download of new URL file:///c:/users/dtaylor/documents/visual studio 2013/Projects/Odata Service/Odata/bin/MongoDB.Bson/MongoDB.Bson.DLL. LOG: Attempting download of new URL file:///C:/Users/dtaylor/AppData/Local/Temp/Temporary ASP.NET Files/root/9b6a506e/5b857965/MongoDB.Bson.EXE. LOG: Attempting download of new URL file:///C:/Users/dtaylor/AppData/Local/Temp/Temporary ASP.NET Files/root/9b6a506e/5b857965/MongoDB.Bson/MongoDB.Bson.EXE. LOG: Attempting download of new URL file:///c:/users/dtaylor/documents/visual studio 2013/Projects/Odata Service/Odata/bin/MongoDB.Bson.EXE. LOG: Attempting download of new URL file:///c:/users/dtaylor/documents/visual studio 2013/Projects/Odata Service/Odata/bin/MongoDB.Bson/MongoDB.Bson.EXE.

StackTrace: at Mongo.Context.MongoMetadata..cctor() InnerException:

object avatar May 21 '14 20:05 object

I need to know more about your project environment. Did you add MongOData NuGet package to a Visual Studio Web project? If so, can you list the content of project folders. It looks like something is fundamentally wrong with the content of project files.

object avatar May 21 '14 20:05 object

Hi,

I ran some tests, and I think the problem may be related to the old version of MongoDB driver that you have. Can you try to update it? Open package manager console and run the following command:

update-package mongocsharpdriver

This should upgrade the driver version to at least 1.9.0.

object avatar May 21 '14 21:05 object

It seems to be working now, except I can't get it to work as a built dll. I have created an excel plugin that uses this service as a dependency, but I'm not sure how to get the service to work when the excel plugin is loaded.

longlostbro avatar May 23 '14 20:05 longlostbro

Is it possible for you to share with me your plugin projects, environment etc.? I can try to figure out how to make it work. You can send me more details at [email protected] or comment here.

object avatar May 24 '14 07:05 object