Search code examples
c#servicestackormlite-servicestack

ServiceStack "Declaration referenced in a method implementation cannot be a final method"


Trying to set up ServiceStack with OrmLite to connect to my local SQL instance. Getting error

"Declaration referenced in a method implementation cannot be a final method"

and it's driving me nuts. Here are my steps so far:

  1. New "ServiceStack ASP.NET Empty" project
  2. In the "Service" project, installed ServiceStack.OrmLite.SqlServer NuGet package
  3. Added the following code to the AppHost "Configure" section:

public override void Configure(Funq.Container container) { var connectionString = ConfigurationManager.ConnectionStrings["ApiDbConnectionString"].ConnectionString; container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider)); OrmLiteConnectionFactory dbFactory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider); }

Here are my using statements:

using System;
using System.IO;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using ServiceStack;
using ServiceStack.Data;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.SqlServer;
using LRIService.ServiceInterface;

I would like to use this database connection throughout the app for caching, data access, and eventually user authentication.

Lastly, are there any good examples of ServiceStack running as a standalone service (not as part of an ASP.NET MVC app)? I am going to be accessing this via a stand-alone AngularJS app that may or may not be hosted on the same domain (I've worked with the CORS feature before). I'm just having trouble separating the ASP.NET MVC stuff from the ServiceStack stuff in many of the examples on the web.

Thanks for any help...


Solution

  • Your error message sounds like you're mixing different versions of ServiceStack together. Try clearing your NuGet packages Cache. Alternatively you can try the most recent v4.0.34 packages on MyGet.

    As for non ASP.NET MVC Examples, most of the ServiceStack Live Demos are Single Page Apps that don't use ASP.NET MVC at all: