Reputation: 57
Getting this error on App startup when Azure DevOps builds my project. App works fine in Visual Studio.
Unhandled exception. System.TypeLoadException: Method 'WriteFileAsync' in type 'ServiceStack.IO.MemoryVirtualFiles' from assembly 'ServiceStack.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at ServiceStack.ServiceStackHost..ctor(String serviceName, Assembly[] assembliesWithServices)
at ServiceStack.AppHostBase..ctor(String serviceName, Assembly[] assembliesWithServices) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\AppHostBase.NetCore.cs:line 31
at WebApp.AppHost..ctor() in D:\a\1\s\NCMSProgram\NCMSProgram\Startup.cs:line 340
at MyCtor()
at ServiceStack.ModularStartup.CreateStartupInstance(Type type)
at ServiceStack.ModularStartup.GetPriorityInstances()
at ServiceStack.ModularStartup.ConfigureServices(IServiceCollection services)
at ServiceStack.ModularStartupActivator.ConfigureServices(IServiceCollection services)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at WebApp.Program.Main(String[] args)
Upvotes: 1
Views: 209
Reputation: 2662
I had a similar issue. The solution noted by mythz in Jan 2022 didn't apply to me as I'm not using preview versions. I'm sharing my solution in hopes that it helps other people who come here
My error was
Method 'ReadAllTextAsync' in type 'ServiceStack.IO.InMemoryVirtualFile' from assembly 'ServiceStack.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
The root cause was my Visual Studio was referencing some ServiceStack v8 packages even though I'm using ServiceStack v.6.10.
Unfortunately, NuGet Package Manager for Solution said I only had v6 packages. I had to expand each project and expand their "Packages" along with each ServiceStack item. It was there that I found ServiceStack (6.10.0) had child nodes ServiceStack.Client (8.0.0), ServiceStack.Common (6.10.0) ServiceStack.Interfaces (8.0.0), ServiceStack.Text (8.0.0)
I uninstalled all the ServiceStack packages then installed ServiceStack -version 6.10.
Upvotes: 1
Reputation: 143369
Whenever you get Type or Missing method exceptions from using the pre-release packages which referenced in yours project NuGet.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="ServiceStack MyGet feed" value="https://www.myget.org/F/servicestack" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Typically it's due to downloading the same pre-release package version at different times which you can resolve by deleting your NuGet packages cache:
$ nuget locals all -clear
Then restoring your packages again which fetches the latest version of each package ensuring they're all built at the same time.
As an added precaution I've rebuilt and deployed all pre-release packages again, so just re-running the task again may also resolve it.
Upvotes: 1