|
I am able to get the same stack trace by putting invalid entries into my App.config file.
Please check your config file, as that is where the problem likely lies.
I would also warn you against calling server.Disconnect as it interferes with connection pooling. Calling Connect is also not necessary (the driver connects automatically) but is harmless, unlike Disconnect which is problematic.
|
|
MongoDB.Driver.MongoConnectionException was unhandled
Message=Unable to connect to server localhost:27017: Configuration system failed to initialize.
Source=MongoDB.Driver
StackTrace:
at MongoDB.Driver.Internal.DirectConnector.Connect(TimeSpan timeout)
at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout, ConnectWaitFor waitFor)
at MongoDB.Driver.MongoServer.Connect(ConnectWaitFor waitFor)
at MongoDB.Driver.MongoServer.ChooseServerInstance(Boolean slaveOk)
at MongoDB.Driver.MongoServer.AcquireConnection(MongoDatabase database, Boolean slaveOk)
at MongoDB.Driver.MongoCollection.InsertBatch(Type nominalType, IEnumerable documents, MongoInsertOptions options)
at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document, MongoInsertOptions options)
at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document)
at MongoDB.Driver.MongoCollection.Insert[TNominalType](TNominalType document)
at mongoDB_project.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\mgunda\my documents\visual studio 2010\Projects\mongoDB_project\mongoDB_project\Form1.cs:line 79
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at mongoDB_project.Program.Main() in c:\documents and settings\mgunda\my documents\visual studio 2010\Projects\mongoDB_project\mongoDB_project\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Configuration.ConfigurationErrorsException
Message=Configuration system failed to initialize
Source=System.Configuration
BareMessage=Configuration system failed to initialize
Line=0
StackTrace:
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.DiagnosticsConfiguration.get_Sources()
at System.Diagnostics.TraceSource.Initialize()
at System.Net.Logging.InitializeLogging()
at System.Net.Logging.get_On()
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
at MongoDB.Driver.MongoServerAddress.ToIPEndPoint(AddressFamily addressFamily)
at MongoDB.Driver.MongoServerInstance.GetIPEndPoint()
at MongoDB.Driver.Internal.MongoConnection.Open()
at MongoDB.Driver.Internal.MongoConnection.GetNetworkStream()
at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, SafeMode safeMode)
at MongoDB.Driver.Internal.MongoConnection.RunCommand(String collectionName, QueryFlags queryFlags, CommandDocument command, Boolean throwOnError)
at MongoDB.Driver.MongoServerInstance.VerifyState(MongoConnection connection)
at MongoDB.Driver.MongoServerInstance.Connect(Boolean slaveOk)
at MongoDB.Driver.Internal.DirectConnector.Connect(TimeSpan timeout)
InnerException: System.Configuration.ConfigurationErrorsException
Message=Unrecognized configuration section ConfigurationManager. (C:\Documents and Settings\mgunda\my documents\visual studio 2010\Projects\mongoDB_project\mongoDB_project\bin\Debug\mongoDB_project.vshost.exe.Config line 3)
Source=System.Configuration
BareMessage=Unrecognized configuration section ConfigurationManager.
Filename=C:\Documents and Settings\mgunda\my documents\visual studio 2010\Projects\mongoDB_project\mongoDB_project\bin\Debug\mongoDB_project.vshost.exe.Config
Line=3
StackTrace:
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
InnerException:
|
|
I did a web search for "Configuration system failed to initialize" and a common cause for that is an invalid App.config file.
Can you attach your config file to the ticket?
Also, can you provide a full stack trace so we can see where the particular exception is coming from?
|