4

I'm trying to add an ASP.NET Core Web API to my application, so external apps can query its in-memory data, although its complaining about missing files on my system.

I installed the Microsoft.AspNet.WebApi.OwinSelfHost package and added this code:

var config = new HttpSelfHostConfiguration("http://localhost:8080");

Now I get this error:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

File name: 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

If I install package System.ServiceModel.Primitives, then I get:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel.Http, Version=4.10.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.ServiceModel.Http, Version=4.10.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

If I install System.ServiceModel.Http then I get:

Unhandled exception. System.TypeLoadException: Could not load type 'System.ServiceModel.HostNameComparisonMode' from assembly 'System.ServiceModel, Version=4.0.0.0,

1 Answer 1

1

This is because there is no the System.ServiceModel.dll version currently for the ASP.NET-Core that contain the HostNameComparisonMode type.

If you go to HostNameComparisonMode Enum page in the Microsoft documentation and select .NET 5, for example, you will receive the following message:

The requested page is not available for .NET 5. You have been redirected to the newest product version this page is available for.

The same for .NET 6/7/8.


NOTE: If you will compile the a project for the .Net Framework 4.8 than the following declaration will appear in the System.ServiceModel.dll:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.