Error in Template using ServiceStack Auth and SQL Server


As a long-term ServiceStack user, firstly let me thank you for an outstanding product!

Now that ServiceStack 8 is out, I’m looking to upgrade some projects written with ServiceStack 6. I’ve downloaded a new template (both from your Website and also from x) using the choices as per screenshot below. I.e. ServiceStack Auth with SQL Server and AutoQuery.

The template in itself downloads fine, but it fails to compile with an error on file Configure.AuthRepository.cs, line 40 on the screenshot below. The error says IServiceProvider does not contain a definition to Resolve.

After some troubleshooting, I went to take a look at the code in Configure.AuthRepository.cs from my ServiceStack 6 projects. I can see that the code is almost identical as the downloaded template, Resolve function from IServiceProvider is present. By looking at the Object Browser, I can see that Resolve() sits within a class called ServiceStack.NetCoreAppHostExtensions (screenshot below).

Looking at the same class in ServiceStack 8, I can see that the Resolve() function is indeed not there.

Is there a workaround for this?

Thank you!


Thx for the kind words!

The error says IServiceProvider does not contain a definition to Resolve.

Ok thanks I’ll look at upgrading the existing mix scripts. As of v8.1. we’re now recommending using ASP.NET Core’s IOC APIs for registering and resolving dependencies so instead of TryResolve<T>() and Resolve<T>() you should use the GetService<T>() and GetRequiredService<T>() extension methods as they’ll be source compatible when later switching to ASP.NET Core’s IOC.

The mix configuration scripts should now be updated, thx for reporting.

Thank you mythz, that solves it!

I’m always amazed at how quickly you can do things, great work.



1 Like