question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET 4.7.1 app referencing fields .NET standard 2.0 can cause missing field exception from select assemblies

See original GitHub issue

Found in D15Rel 27110.0 1.Create a .NET 4.7.1 C# console app and a ,NET Standard 2.0 class library. 2. Inside the Class Library add the following field/constructor to the class.

public System.Net.Http.StringContent StringContent;
        public Class1()
        {
            StringContent = new System.Net.Http.StringContent("asdf");
        }
  1. Add a reference from the class library to the console app.
  2. Add some code to reference StringContent in the Main method of the console app such as:
Class1 c= new Class1();
c.StringContent.GetType();
  1. Start debugging

Expected: Application builds fine and runs fine.

Actual: Application breaks during execution. Following is found in the output: An unhandled exception of type ‘System.MissingFieldException’ occurred in Unknown Module. Field not found: ‘ClassLibrary1.Class1.StringContent’.

This also occurs with System.IO.Compression.ZipArchive

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
joperezrcommented, Jan 29, 2018

@livarcocc yeah he meant it the other way around, and also, this problem will be fixed in VS 15.6 Preview 3. What is happening here is that we don’t automatically create a binding redirect to System.Net.Http on the apps config, after adding it manually the but doesn’t repro anymore:

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
          </dependentAssembly>
        </assemblyBinding>
    </runtime>

@livarcocc this is the fix that we took in for VS 15.6 preview 3 a few weeks ago by updating the support package that will be inserted.

0reactions
livarcocccommented, Jan 29, 2018

@mattscheffer and @joperezr thanks for replying.

Given that we have the fix in already and 15.6 preview3 is out the door, I am going to close this issue.

@mattscheffer if this still reproes with 15.6 Preview3, just comment and we can re-activate and continue investigating.

Read more comments on GitHub >

github_iconTop Results From Across the Web

You must add a reference to assembly 'netstandard ...
NET Core SDK 2.0 and .NET Framework 4.7.1 installed in my machine but I don't want to include a reference to it. This...
Read more >
Add a reference to assembly netstandard error with .NET ...
A .NET Framework 4.6.1 project which has a reference to a nuget package built with .netstandard2.0 is no more building.
Read more >
Migrate from .NET Framework to .NET Core (.NET 6)
In this article, we will learn about the things you should consider and focus on while migrating your existing applications from .NET ......
Read more >
C# 11 and . NET 7 - Modern Cross-Platform Development ...
NET Standard • 16 .NET platforms and tools used by the C# and .NET book editions • 17. Topics covered by Apps and...
Read more >
MySQL Connector/NET Developer Guide
This manual describes how to install and configure MySQL Connector/NET, the connector that enables .NET applications to communicate with MySQL servers, and how ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found