LINQPad 6 v.6.5.5 MissingMethodException Thrown When Running a C# Program with System.Net.Dns
Greetings;
I'm having difficulties running a C# Program in LINQPad that references and calls Dns.GetHostName(), Dns.GetHostAddresses() and the IPAddress class from a C# Program in LINQPad 6 v6.5.5 (x64). My program implementation is as follows:
void Main() { string hostname = Dns.GetHostName(); if (!string.IsNullOrEmpty(hostname)) { var ipAddresses = Dns.GetHostAddresses(hostname); if (ipAddresses != null && ipAddresses.Length >= 1) { foreach (IPAddress ipAddress in ipAddresses) { Console.WriteLine($" {ipAddress}"); } } } }
My assembly references and namespace imports for the program are as follows:
Additional References:
System.dll
System.Net.dll
System.Net.NameResolution.dll
System.Net.Primitives.dll
Location for all References: C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Namespace Imports:
System
System.Collections
System.Collections.Generic
System.Data
System.Diagnostics
System.IO
System.Linq
System.Linq.Expressions
System.Reflection
System.Text
System.Text.RegularExpressions
System.Threading
System.Transactions
System.Xml
System.Xml.Linq
System.Xml.XPath
System.Net
When I execute the program either with or without the debugger attached, LINQPad 6 dispalys the following error message above the program script and just below the toolbar:
MissingMethodException: Method not found: 'Void System.Configuration.ConfigurationProperty..ctor(System.String, System.Type, System.Object, System.ComponentModel.TypeConverter, System.Configuration.ConfigurationValidatorBase, System.Configuration.ConfigurationPropertyOptions)'.
The Stack Trace for the MissingMethodException displayed in LINQPad is as follows:
Any help or insights on how I can correct my C# Program to resolve this exception being thrown would be greatly appreciated.
Thank you.
Comments
How and why are you adding Framework 4 references?
You shouldn't need any additional references, and just one namespace System.Net
See http://share.linqpad.net/tgfuie.linq
Thank you for the feedback and correction, sgmoore, Misinterpreted and misapplied what I read with regards to the static Dns class reference on Microsoft Docs.