I have a large number of .NET Framework 4.8 applications. They extensively use System.Web, which is a framework only API. To ease the transition to .NET Core/.NET 5+, I would like to extract some of the functionalities of the framework code into .NET Standard libraries.
This will create the situation where my new core applications are calling standard libraries that may reference framework application code to do their job while that code is not yet updated. Is this even possible? Can standard libraries instantiate framework classes that make use of framework only APIs like system.web?
In my current situation I have 3 classes in three separate projects in 2 solutions.
Solution A
StandardClass (.NET Standard 2.0)
TestClass (.NET Core 3.1, MSTest)
Solution B
FrameworkClass (.NET Framework 4.8)
Solution B
builds to a dll that is referenced by Solution A
. My TestClass
creates an instance of StandardClass
and calls StandardClass.Foo()
.
StandardClass
has a property _frameworkClass
of type FrameworkClass
, initialized in StandardClass
's constructor.
StandardClass.Foo()
calls _frameworkClass.Bar()
and it returns a string, but Bar()
uses System.Web.HttpContext throughout the course of it's processes, amoungst other System.Web classes. So when StandardClass.Foo()
fires, I get the error that System.Web.HttpContext cannot be loaded from System.Web
I figured that as long as StandardClass
does not know about what classes FrameworkClass
is using to do its job, then it would be fine.