2

I have NET Standard project with Person.cs file. Then I also have .NET Framework 4.6.2 library project. I have added Person.cs in .NET Framework 4.6.2 project as existing item and as a link from NETStandard project. ( because I wanted to keep same copy of person.cs in both the projects)

The Person class in .NET Standard will get compiled with target framework .NET Standard, but will Person class in .NET Framework 4.6.2 get complied as .NET Framework 4.6.2?

enter image description here

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
LP13
  • 30,567
  • 53
  • 217
  • 400

1 Answers1

1

The person class in NETStandard will get compiled with target framework NETStandard, but will person class in .NET 4.6.2 get complied as .NET 4.6.2?

Yes.

BUT, the two Person classes will not be considered the same type by the .NET compiler. You won't be able to use an instance of Person from the NETStandardLib to assign a variable of type Person from the NET4.6.2Lib. If you want them to be considered the same type, delete the file link in NET4.6.2Lib, and add a NETStandardLib project reference to NET4.6.2Lib. All versions of .NET Standard can be consumed by .NET Framework 4.6.2, so this won't be a problem.

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • That was the initial intention. However its not straight forward. I encountered lot of issues when i shared NET Standard project with .NET 4.6.2 project. One of the issue is here https://stackoverflow.com/questions/48716008/asp-net-web-api-2-cannot-return-stream-when-net-standard-1-6-project-is-referenc Also check https://github.com/dotnet/standard/issues for issues related to sharing NET Standard with Full .NET I have already spent couple of days to resolve, but finally i have decided to create project specific to Full .NET Framework that will link files from NET Standard project. – LP13 Feb 14 '18 at 17:37