Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DnsClient.DnsResponseException: Unhandled exception (FileNotFoundException: System.Buffers, Version=4.0.2.0) in .NET Framework 4.7.2 #59

Closed
GHosaPhat opened this issue Mar 5, 2020 · 5 comments

Comments

@GHosaPhat
Copy link

GHosaPhat commented Mar 5, 2020

I'm using the most recent NuGet package available for DnsClient (v1.2.0), which states in its dependencies that it uses System.Buffers >= 4.4.0 under the .NET Framework 4.7.1. I also have the current NuGet package for System.Buffers (4.5.0) installed in the project, however my application has been raising the above exception when it attempts to execute DnsClient.LookupClient.Query("domainname", DnsClient.QueryType.MX)

I realize that I'm using a slightly newer version of the .NET Framework (4.7.2 instead of 4.7.1) and that this could be the source of the issue. Also, I don't have the debugger set to break on these exceptions, so it is able to continue execution without too much headache, but I'm just wondering why it appears to be looking for the much older version 4.0.2.0 of the System.Buffers library instead of at least 4.4.0.

I'm using this in an e-mail address validation method, and the problem is that the exception causes pretty much every e-mail address I test to come back as invalid since it won't retrieve the MX record for the domain.

@MichaCo
Copy link
Owner

MichaCo commented Mar 5, 2020

4.0.2.0 is the internal assembly version of System.Buffers of the Nuget version 4.4.0
4.0.3.0 would be from Nuget version 4.5.0 (you can figure that out when you extract the nuget and the included dlls)

Is your app an using the old (before .NET Core) project system? Then you might need a proper assembly redirect in your app/web.config.
If you use <packageReferences> in your project file, make sure you don't have a packages.config file, too

There are also a bunch of issues related to those kind of errors and .NET 4.7.2 on the dotnet/runtime and dotnet/standard github repository. Maybe you check that out, too.
For example dotnet/standard#481

@GHosaPhat
Copy link
Author

GHosaPhat commented Mar 5, 2020

All right. I'll take a look. This is for a library I've built for my internal desktop applications, so there isn't a web.config file, but I'll look into the assembly redirection for the app.config. The project file does contain <packageReference> items for most of my referenced assemblies and there is no packages.config file. I'll do some additional digging around in the repos you mentioned as well. Perhaps I simply need to roll back my System.Buffers version from NuGet to 4.4.0 for now and see if that breaks anything else.

@MichaCo
Copy link
Owner

MichaCo commented Mar 5, 2020

If you cannot figure it out, try to reproduce it in a simple project or let me know what exactly you use. VS version, project / solution type..

@GHosaPhat
Copy link
Author

GHosaPhat commented Mar 5, 2020

Well, crap. I downgraded the System.Buffers version to 4.4.0 and ran a quick debug test where I got a couple of additional warnings from some of the other assemblies I use (like Npgsql), so I brought it back up to 4.5.0 and tried to generate the exception so I could populate the redirect element in the app.config. This time, I didn't see any exceptions from DnsClient. Perhaps something just needed to be "refreshed" somewhere... IDK.

EDIT: Going and looking at the app.config, I see that there's apparently already a redirection entry for System.Buffers that specifies all old/current versions point to 4.0.3.0... Maybe that's where the problem was all along (I didn't look at it before I downgraded). Again, I'm not sure, but I'm going to basically have to assume that all is well now.

      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>

@MichaCo MichaCo closed this as completed Mar 5, 2020
@moderndev
Copy link

im getting this same issue ... when i upgraded to 4.7.2 or 4.8, and dnsclient >1.3.0 ..

I'll try to get a reproduction example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants