Search code examples
c#servicestackormlite-servicestackservicestack-autoquery

Servicestack AutoQuery -> System.TypeLoadException Error


I'm trying to servicify an existing RDBMS with C# AutoQuery, but getting this error:

  HResult=0x80131522
  Message=Type 'WebApplication1.ServiceModel.CreateCurrency' from assembly 'tmpCrudAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.
  Source=ServiceStack
  StackTrace:
   at ServiceStack.ServiceStackHost.OnStartupException(Exception ex)
   at ServiceStack.ServiceStackHost.OnStartupException(Exception ex, String target, String method)
   at ServiceStack.ServiceStackHost.RunPostInitPlugin(Object instance)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at ServiceStack.ServiceStackHost.RunAfterPluginsLoaded(String specifiedContentType)
   at ServiceStack.ServiceStackHost.OnAfterInit()
   at ServiceStack.ServiceStackHost.Init()
   at ServiceStack.NetCoreAppHostExtensions.UseServiceStack(IApplicationBuilder app, AppHostBase appHost)
   at Program.<Main>$(String[] args) in C:\Users\User\Desktop\Test\WebApplication1\WebApplication1\Program.cs:line 9

The target database is a mySQL database using BINARY(16) as primary key. Could this be the problem? When I target another mySQL database it's working like it should.


Solution

  • You can control the tables that AutoGen generates the data models and APIs for when configuring the GenerateCrudServices instruction, e.g you can exclude a specific table with:

    Plugins.Add(new AutoQueryFeature {
        GenerateCrudServices = new GenerateCrudServices {
            ExcludeTables = { "Currency" },
        }
    });