2
votes

We have Web application based on ServiceStack. It works currently with .NET 4.5.2. We are trying to rearrange it to allow the application to run with NET CORE and with .NET.

I tried to create Assembly containing main part of the application, compile this Assembly with .NET Standard and use it from 2 different environments: .NET CORE and .NET under IIS (each environment has its own startup dll, one with Program/Startup, another with Global.asax)

The question is what ServiceSTack flavor to use in that .NET Standard Assembly. I tried to use ServiceStack Core, but it failed with "MVC Services have not been configured, Please add services.AddMvc() to StartUp.ConfigureServices()" when used under IIS, then I tried ServiceStack regular nuget and got: "Could not load file or assembly 'ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies."

How it is supposed to work?

1

1 Answers

1
votes

Please see this answer and follow/read all links and sources:

https://stackoverflow.com/a/51252374/85785

You cannot mix .NET Framework and .NET Standard assemblies in the same project, if you need to support both .NET Standard and .NET Framework dependencies your projects need to multi-target.

If you want to port to an ASP.NET Core project on the .NET Framework you need to reference the .Core packages, see this docs for details:

http://docs.servicestack.net/templates-corefx

If you want to port to and ASP.NET Core project on the .NET Core runtime you can reference the normal ServiceStack NuGet packages which contains .NET Standard 2.0 builds for most packages.

If you're using Razor or MVC you'll need to enable MVC in your ASP.NET Core App. See these templates below for examples of working projects on .NET Core: