[CSHARP-2330] DnsClient.IDnsQueryResponse exception during Mongoclient Created: 13/Jul/18  Updated: 05/Apr/19  Resolved: 07/Jan/19

Status: Closed
Project: C# Driver
Component/s: Configuration, Connectivity
Affects Version/s: 2.7.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Vicky Nadella Assignee: Unassigned
Resolution: Duplicate Votes: 1
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

VS 2017 , Win 7


Issue Links:
Duplicate
duplicates CSHARP-2453 Latest DnsClient breaks API compatibi... Closed
Related
is related to CSHARP-2453 Latest DnsClient breaks API compatibi... Closed
Case:

 Description   

While Im trying to establish mongoclient Im getting the following error

$exception {"Method not found: 'DnsClient.IDnsQueryResponse DnsClient.LookupClient.Query(System.String, DnsClient.QueryType)'."} System.MissingMethodException

My Code looks like below (exception at highlighted in red)

const string connstring = "mongodb+srv://<USR>:<PWD>@sieberrlog-nlbll.mongodb.net/test?retryWrites=true";
MongoClient client = new MongoClient(connstring);
var db = client.GetDatabase("SiebErrorMsg");

 

My packages.config is

<packages>
<package id="Costura.Fody" version="3.1.0" targetFramework="net452" />
<package id="DnsClient" version="1.1.1" targetFramework="net452" />
<package id="Fody" version="3.1.3" targetFramework="net452" developmentDependency="true" />
<package id="LiteDB" version="4.1.4" targetFramework="net452" />
<package id="MetroFramework" version="1.2.0.3" targetFramework="net452" />
<package id="MetroFramework.Design" version="1.2.0.3" targetFramework="net452" />
<package id="MetroFramework.Fonts" version="1.2.0.3" targetFramework="net452" />
<package id="MetroFramework.RunTime" version="1.2.0.3" targetFramework="net452" />
<package id="MongoDB.Bson" version="2.7.0" targetFramework="net452" />
<package id="MongoDB.Driver" version="2.7.0" targetFramework="net452" />
<package id="MongoDB.Driver.Core" version="2.7.0" targetFramework="net452" />
<package id="System.Buffers" version="4.5.0" targetFramework="net452" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" />
</packages>

Following is more details of exception:

  Name Value Type
$exception {"Method not found: 'DnsClient.IDnsQueryResponse DnsClient.LookupClient.Query(System.String, DnsClient.QueryType)'."} System.MissingMethodException
  ClassName null string
  ▶ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
  HResult -2146233069 int
  HelpLink null string
  ▶ InnerException null System.Exception
  MemberName null string
  Message "Method not found: 'DnsClient.IDnsQueryResponse DnsClient.LookupClient.Query(System.String, DnsClient.QueryType)'." string
  Signature null byte[]
  Source "MongoDB.Driver.Core" string
  StackTrace " at MongoDB.Driver.Core.Configuration.ConnectionString.Resolve()\r\n at MongoDB.Driver.MongoUrl.Resolve()\r\n at MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)\r\n at MongoDB.Driver.MongoClient..ctor(String connectionString)\r\n at AdvancedSiebelLogScanner.Form1.metroButton5_Click(Object sender, EventArgs e) in E:
ANZ Data Backup
Siebel Accelerators\\AdvancedSiebelLogScanner-master\\AdvancedSiebelLogScanner
Form1.cs:line 472\r\n at System.Windows.Forms.Control.OnClick(EventArgs e)\r\n at System.Windows.Forms.Button.OnClick(EventArgs e)\r\n at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\r\n at MetroFramework.Controls.MetroButton.OnMouseUp(MouseEventArgs e)\r\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.ButtonBase.WndProc(Message& m)\r\n at System.Windows.Forms.Button.WndProc(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at AdvancedSiebelLogScanner.Program.Main() in E:
ANZ Data Backup
Siebel Accelerators\\AdvancedSiebelLogScanner-master\\AdvancedSiebelLogScanner
Program.cs:line 19"
string
  ◢ TargetSite {MongoDB.Driver.Core.Configuration.ConnectionString Resolve()} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
  Attributes Public | HideBySig System.Reflection.MethodAttributes
  CallingConvention Standard | HasThis System.Reflection.CallingConventions
  ContainsGenericParameters false bool
  ▶ CustomAttributes Count = 0 System.Collections.Generic.IEnumerable<System.Reflection.CustomAttributeData> {System.Collections.ObjectModel.ReadOnlyCollection<System.Reflection.CustomAttributeData>}
  ◢ DeclaringType {Name = "ConnectionString" FullName = "MongoDB.Driver.Core.Configuration.ConnectionString"}|System.Type {System.RuntimeType}|
| |▶ Assembly|{MongoDB.Driver.Core, Version=2.7.0.0, Culture=neutral, PublicKeyToken=null}|System.Reflection.Assembly {System.Reflection.RuntimeAssembly}|
| |AssemblyQualifiedName|"MongoDB.Driver.Core.Configuration.ConnectionString, MongoDB.Driver.Core, Version=2.7.0.0, Culture=neutral, PublicKeyToken=null"|string|
| |Attributes|Public | Sealed | BeforeFieldInit|System.Reflection.TypeAttributes|
| |▶ BaseType|{Name = "Object" FullName = "System.Object"}|System.Type {System.RuntimeType}|
| |ContainsGenericParameters|false|bool|
| |▶ CustomAttributes|Count = 0|System.Collections.Generic.IEnumerable<System.Reflection.CustomAttributeData> {System.Collections.ObjectModel.ReadOnlyCollection<System.Reflection.CustomAttributeData>}|
| |▶ DeclaredConstructors|{System.Reflection.ConstructorInfo[1]}|System.Collections.Generic.IEnumerable<System.Reflection.ConstructorInfo> {System.Reflection.ConstructorInfo[]}|
| |DeclaredEvents|{System.Reflection.EventInfo[0]}|System.Collections.Generic.IEnumerable<System.Reflection.EventInfo> {System.Reflection.EventInfo[]}|
| |▶ DeclaredFields|{System.Reflection.FieldInfo[43]}|System.Collections.Generic.IEnumerable<System.Reflection.FieldInfo> {System.Reflection.FieldInfo[]}|
| |▶ DeclaredMembers|{System.Reflection.MemberInfo[153]}|System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo> {System.Reflection.MemberInfo[]}|
| |▶ DeclaredMethods|{System.Reflection.MethodInfo[65]}|System.Collections.Generic.IEnumerable<System.Reflection.MethodInfo> {System.Reflection.MethodInfo[]}|
| |▶ DeclaredNestedTypes|{System.Reflection.TypeInfo.<get_DeclaredNestedTypes>d__23}|System.Collections.Generic.IEnumerable<System.Reflection.TypeInfo> {System.Reflection.TypeInfo.<get_DeclaredNestedTypes>d__23}|
| |▶ DeclaredProperties|{System.Reflection.PropertyInfo[39]}|System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> {System.Reflection.PropertyInfo[]}|
| |▶ DeclaringMethod|'((System.RuntimeType)((System.Reflection.RuntimeMethodInfo)($exception).TargetSite).DeclaringType).DeclaringMethod' threw an exception of type 'System.InvalidOperationException'|System.Reflection.MethodBase {System.InvalidOperationException}|
| |▶ DeclaringType|null|System.Type|
| |FullName|"MongoDB.Driver.Core.Configuration.ConnectionString"|string|
| |▶ GUID|{a08b7a87-8543-3e3b-8add-d998753ceac4}|System.Guid|
| |▶ GenericParameterAttributes|'((System.RuntimeType)((System.Reflection.RuntimeMethodInfo)($exception).TargetSite).DeclaringType).GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'|System.Reflection.GenericParameterAttributes {System.InvalidOperationException}|
| |▶ GenericParameterPosition|'((System.RuntimeType)((System.Reflection.RuntimeMethodInfo)($exception).TargetSite).DeclaringType).GenericParameterPosition' threw an exception of type 'System.InvalidOperationException'|int {System.InvalidOperationException}|
| |GenericTypeArguments|{System.Type[0]}|System.Type[]|
| |GenericTypeParameters|{System.Type[0]}|System.Type[]|
| |HasElementType|false|bool|
| |ImplementedInterfaces|{System.Type[0]}|System.Collections.Generic.IEnumerable<System.Type> {System.Type[]}|
| |IsAbstract|false|bool|
| |▶ Module (System.Reflection.MemberInfo)|{MongoDB.Driver.Core.dll}|System.Reflection.Module {System.Reflection.RuntimeModule}|
| |▶ Module|{MongoDB.Driver.Core.dll}|System.Reflection.Module {System.Reflection.RuntimeModule}|
| |Name|"ConnectionString"|string|
| |Namespace|"MongoDB.Driver.Core.Configuration"|string|
| |▶ ReflectedType|null|System.Type|
| |▶ StructLayoutAttribute|{System.Runtime.InteropServices.StructLayoutAttribute}|System.Runtime.InteropServices.StructLayoutAttribute|
| |▶ TypeHandle|{System.RuntimeTypeHandle}|System.RuntimeTypeHandle|
| |▶ TypeInitializer|null|System.Reflection.ConstructorInfo|
| |▶ UnderlyingSystemType|{Name = "ConnectionString" FullName = "MongoDB.Driver.Core.Configuration.ConnectionString"}
System.Type {System.RuntimeType}
  ▶ Static members    
  ▶ Non-Public members    
  MemberType Method System.Reflection.MemberTypes
  MetadataToken 100664189 int
  ▶ MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle
  MethodImplementationFlags IL System.Reflection.MethodImplAttributes
  ▶ Module {MongoDB.Driver.Core.dll} System.Reflection.Module {System.Reflection.RuntimeModule}
  Name "Resolve" string
  ▶ ReflectedType {Name = "ConnectionString" FullName = "MongoDB.Driver.Core.Configuration.ConnectionString"}|System.Type {System.RuntimeType}|
| |▶ ReturnParameter|{MongoDB.Driver.Core.Configuration.ConnectionString }|System.Reflection.ParameterInfo {System.Reflection.RuntimeParameterInfo}|
| |▶ ReturnType|{Name = "ConnectionString" FullName = "MongoDB.Driver.Core.Configuration.ConnectionString"}
System.Type {System.RuntimeType}
  ▶ ReturnTypeCustomAttributes {MongoDB.Driver.Core.Configuration.ConnectionString } System.Reflection.ICustomAttributeProvider {System.Reflection.RuntimeParameterInfo}
  ▶ Non-Public members    
  ▶ Static members    
  ▶ Non-Public members    

 

 



 Comments   
Comment by keymoon [ 14/Aug/18 ]

I found the solution of this problem.

 

DnsClient 1.1.1 cause this error. downgrade to 1.0.7, and try again.

if you see error "Could not load file or assembly 'DnsClient' or one of its dependencies. Manifest definition does not match the assembly reference",make sure to check redirect setting in web.config. newVersion section in "dependentAssembly/bindingRedirect" should be "1.0.7.0".

 <assemblyIdentity name="DnsClient" publicKeyToken="4574bb5573c51424" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.7.0" newVersion="1.0.7.0" />

Comment by keymoon [ 14/Aug/18 ]

I have same issue too.

code is here:

https://github.com/key-moon/ac-predictor/blob/87edbf08f721bc17e041535ba238d6db8b6681ba/ac-predictor/MongoDB/APrefsDB.cs#L30

connection string:mongodb+srv://admin:{pass}@ac-predictor-th1oa.mongodb.net/?retryWrites=true

https://pastebin.com/yCJTUswq(package config)

https://pastebin.com/xHcMr2uj(detail of exception)

Generated at Wed Feb 07 21:42:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.