Could not load file or assembly 'System.Web.Services, Version=2.0.0.0 error in asp.net core 3.1 solution

Viewed 2909

I am working on Asp.Net Core 3.1 solution. I have an requirement where i need to add an another Asp.Net dll build in .Net Framework 2.0. When i add that dll in my core solution it builds correctly but it is giving me runtime error Could not load file or assembly 'System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Can anyone please help me to resolve the issue ?

2 Answers

It is not possible. You can only reference dll's compiled for .net core or .net standard (not .net framework). You will either have to recompile the dll if you own the code to target .net standard, or find a replacement if you don't.

I think what you need to do is install the .net Framework 3.5 features. As you're trying to use a dll which relies on .Net Framework 2.0 (which is almost 15 years old!), the components are not installed by default for these to run anymore. Installing the older framework (which there is instructions on how to do here) should install the prerequisites for your ancient DLL to load.

HOWEVER, I wouldn't expect this to work too well. While you can use .net Framework DLLs from .Net Core, it uses the .Net Standard Compatibility Shim, which allows you to compile apps which reference older DLLs from core. It does not guarantee however that they will work.

As the shim is for .Net Standard, it can only target as low as .Net Framework 4.5, so if it does work, you should count yourself very lucky, and seek a newer version of your asp.Net 2.0 based dll. Well, you should do that anyway. There's almost no valid reason to be trying to use .net core 3 with ANCIENT assemblies built before some people on this website were even born.

Related