How to create 2.0 Standard project referencing core library and using 2.0 standard in 4.8 framework project example

Spunny

New member
Joined
Nov 25, 2024
Messages
2
Programming Experience
10+
Hi,
We have 4.8 framework asp.net project\application. Have done few business logic in core project. Need to reference core library in 4.8 framework asp.net project and use that code.
So confusing when I read articles. 2.0 standard console project can be used as bridge. Can some one provide me websites with complete examples of how to do it.
Do I need to write code in 2.0 standard console project?

TIA
 
.Net Standard is only relevant for class libraries. Version 2.0 is the last that supports .Net Framework apps, .Net apps can use that too.

1732559998703.png


Within a solution you can use project reference, from a different solution you can reference the library (dll) directly or as a Nuget package if you have published that.
 
Thanks John. Is there an example of 2.0 standard project code. Some say, need to create view models for .core objects. So, not sure exactly where to start or what to do.
 
You just create a regular class library (and target .Net Standard).

As outlined in article the API is more limited than if you created for example a .Net Framework 4.8 library or a .Net 8.0 library since it must support any .Net implementation listed for that version.
 
I think part of the reason you are having difficulty finding examples and articles is because you keep using the term "2.0 standard". As @JohnH tried to point out, you should use the term ".Net Standard 2.0" instead.

Anyway as mentioned above, just create a regular class library. When the Visual Studio wizard asks you what framework to target, select .Net Standard 2.0, instead of the likely default ".NET Framework 4.8" or ".NET 8.0".

That library that you created can then be referenced by other code that is targeted for .NET Framework 4.8, or .NET 8.0.
 
Back
Top Bottom