Exception after upgrade

I just updated all servicestack packages to 5.4 and also updated Microsoft.AspNetCore.App package to 2.1.4.

Locally project runs fine but when I publish to Ubuntu 18.04 running .net core 2.1.4 the app fails to start and gives this exception:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.AspNetCore.Mvc.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at ServiceStack.PclExport.IsDebugBuild(Assembly assembly)
   at ServiceStack.ServiceStackHost.OnConfigLoad()
   at ServiceStack.AppHostBase.OnConfigLoad()
   at ServiceStack.ServiceStackHost.Init()
   at ServiceStack.NetCoreAppHostExtensions.UseServiceStack(IApplicationBuilder app, AppHostBase appHost)
   at SEODomainAuction.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in E:\Clients\Turma\SEODomainAuction\SEODomainAuction\SEODomainAuction\Startup.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at SEODomainAuction.Program.Main(String[] args) in E:\Clients\Turma\SEODomainAuction\SEODomainAuction\SEODomainAuction\Program.cs:line 38

I am publishing as self contained. I am not directly referencing Microsoft.AspNetCore.Mvc.Core as I am not using MVC, it is based on the servicestack angular spa template.

Is this related to a ServiceStack dependency?

The issue says:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

So maybe your dev and deployment machines aren’t using the same .NET Core version? Why is it looking for v2.1.2 if you’ve said you’ve updated to 2.1.4? Are all your NuGet dependencies updated?

This the MyApp.csproj of angular-spa template, there’s no reference to MVC in ServiceStack but there is in Microsoft.AspNetCore.App meta package.

Yeah that’s what confused me as I’m not referencing it. I am running sdk version 2.1.402 on both local and server but my local has older versions still installed.

I cleared nuget cache, deleted bin folder and re-published and now it works. It must have been an old version cached I guess.

Sorry to take your time.

1 Like