aspnetcore: Update to SDK 2.2.100 throws "An item with the same key has already been added. Key: .wasm"
I updated my Blazor project from 2.2.100-preview3-009430 to 2.2.100 release. I now get the following exception:
System.ArgumentException : An item with the same key has already been added. Key: .wasm
Stack Trace:
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.CreateContentTypeProvider(Boolean enableDebugging)
at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.UseBlazor(IApplicationBuilder app, BlazorOptions options)
at Microsoft.AspNetCore.Builder.ServerSideBlazorApplicationBuilderExtensions.UseServerSideBlazor[TStartup](IApplicationBuilder builder)
at OpenGraphTilemaker.Web.Server.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\Users\flynn\Projects\OpenGraphTilemaker\src\OpenGraphTilemaker.Web.Server\Startup.cs:line 36
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateServer(IWebHostBuilder builder)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer()
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)
at OpenGraphTilemaker.Web.Client.Tests.FunctionalTests.Get_EndpointsReturnSuccessAndCorrectContentType(String url) in C:\Users\flynn\Projects\OpenGraphTilemaker\tests\OpenGraphTilemaker.Web.Client.Tests\FunctionalTests.cs:line 25
--- End of stack trace from previous location where exception was thrown ---
The line
app.UseServerSideBlazor<Client.Startup>();
seems to be the reason.
Any suggestions?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 26 (8 by maintainers)
Thanks everyone for reporting this issue! I apologize for the inconvenience.
To workaround this issue you will need to have your Blazor projects continue to target .NET Core 2.1 (netcoreapp2.1). We aren’t planning to patch this issue because there is a workaround and we are currently focused on getting Razor Components into .NET Core 3.0. This issue will be fixed once we release the first public preview of Razor Components early next year.
@danroth27 So to summarize, there is currently no support for Blazor on .NET Core 2.2?
@danroth27 is there any chance to get a hotfix for this?
It looks like
was recently added to
FileExtensionContentTypeProvider: https://github.com/aspnet/AspNetCore/blob/master/src/StaticFiles/src/Microsoft.AspNetCore.StaticFiles/FileExtensionContentTypeProvider.cs (Commit: https://github.com/aspnet/StaticFiles/commit/a5fcd9dd8724eb71f0642340f68aeb85b0473374#diff-3534185c350428a9c533fe5c29596890)The UseBlazor method calls CreateContentTypeProvider which will always fail as a result of the .wasm addition:
Update: The issue has been addressed as part of this commit: https://github.com/aspnet/AspNetCore/commit/5c1fbe1af7b8b6a36289de0d175608a16a1e284c#diff-0cff27aae9e3ba66997ab8244a54fa57
@isaac2004 That’s correct. And instead of spending time patching it we are focusing our efforts on getting Razor Components working in .NET Core 3.0.
I got the exactly same issue this morning. Rolling back to 2.1 framework is fine.
My workaround is simpler. Just use this
global.json. Done.And you need of course the corresponding SDK installed 😸 Even my updates mentioned earlier work fine.
@sheryever Could you please open a new issue with the full details on how to reproduce the problem you are seeing?
@ctrl-alt-d Looks like your app must still be using the earlier packages (Blazor 0.7.0?). It’s only fixed in the newer bits we haven’t released yet.
John,
You’re right. I missed the change to CreateContentTypeProvider() as I read through the change set.
Best regards,
Metro.
Sent from my iPad
On Dec 12, 2018, at 5:56 PM, John Cornell <notifications@github.commailto:notifications@github.com> wrote:
@msauperhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmsauper&data=02|01||eab718084024429c8ceb08d660850427|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636802521742252794&sdata=iKxrlbXdEk%2BL%2B0QhD4wP6f%2F6R4%2FUo3opi5ugsxRiR%2FA%3D&reserved=0 In the commit that I linked to: aspnet/AspNetCore@5c1fbe1#diff-0cff27aae9e3ba66997ab8244a54fa57https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faspnet%2FAspNetCore%2Fcommit%2F5c1fbe1af7b8b6a36289de0d175608a16a1e284c%23diff-0cff27aae9e3ba66997ab8244a54fa57&data=02|01||eab718084024429c8ceb08d660850427|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636802521742252794&sdata=gCBzuKDR3mJYxTBO105huB%2Fo%2B7fS9wb%2FZ2fVtzR0o2c%3D&reserved=0 the Additions are using the same AddMapping() logic:
private static IContentTypeProvider CreateContentTypeProvider(bool enableDebugging) { var result = new FileExtensionContentTypeProvider(); AddMapping(result, “.dll”, MediaTypeNames.Application.Octet); AddMapping(result, “.wasm”, WasmMediaTypeNames.Application.Wasm);
}
private static void AddMapping(FileExtensionContentTypeProvider provider, string name, string mimeType) { if (!provider.Mappings.ContainsKey(name)) { provider.Mappings.Add(name, mimeType); } }
Or am I misunderstanding what you’re saying?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faspnet%2FBlazor%2Fissues%2F1750%23issuecomment-446775578&data=02|01||eab718084024429c8ceb08d660850427|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636802521742252794&sdata=OQ5xuVjNUfbwIpgS719ciq%2BToVkXJOokxAsrW%2BiXkO4%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADottvAYL8GcZU8KK0-HhyDo2V9GhJaOks5u4YmMgaJpZM4ZCVjx&data=02|01||eab718084024429c8ceb08d660850427|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636802521742252794&sdata=pp3L2EbjaKa3lu5MG%2FsLKHKK8yBqEXdZj801NQuBCGY%3D&reserved=0.
@michaelvolz interesting stuff … based on this global.json is no more and it’s replaced by *.csproj Opening mine yielded some interesting stuff - I was using 2.1.500 (no matter that I choose .NET Core 2.2 upon solution creation - using Visual Studio 2017 community) and when changed to 2.2 - it did gives me error on windows too with the same exception. Will update to latest preview to see if it’s working on linux. Thanks for pointing me to the right direction.