Publish fails when blazor app uses BlazorWasmAntivirusProtection Nuget in the project
See original GitHub issueSometimes blazor apps dlls are flagged as false positive and blocked by firewalls or antiviruses. There is already an issue 36978 tracking this.
Meanwhile there is an another great library BlazorWasmAntivirusProtection which is used to overcome this false flagging of blazor apps by antivirus or firewall.
When we use this BlazorWasmAntivirusProtection library and try to prerender, publish fails!!!.
Here is the repo - BlazorWasmAVPrerender to replicate the issue.
Error log:
BlazorWasmAVPrerender -> /home/runner/work/BlazorWasmAVPrerender/BlazorWasmAVPrerender/dist/BlazorWasmAVPrerender/
Unhandled exception. System.Exception: Could not load the assembly "BlazorWasmAVPrerender" in search directories below.
/home/runner/work/BlazorWasmAVPrerender/BlazorWasmAVPrerender/dist/BlazorWasmAVPrerender/wwwroot/_framework
(pwd: /home/runner/work/BlazorWasmAVPrerender/BlazorWasmAVPrerender/BlazorWasmAVPrerender)
---> System.BadImageFormatException: Could not load file or assembly 'BlazorWasmAVPrerender, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.
File name: 'BlazorWasmAVPrerender, Culture=neutral, PublicKeyToken=null' ---> System.BadImageFormatException: Bad IL format.
at System.Runtime.Loader.AssemblyLoadContext.InternalLoad(ReadOnlySpan`1 arrAssembly, ReadOnlySpan`1 arrSymbols)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromStream(Stream assembly, Stream assemblySymbols)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromStream(Stream assembly)
at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.LoadAssemblyFrom(String assemblyDir, String assemblyName) in C:\Projects\My\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 36
at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.<>c__DisplayClass1_0.<.ctor>b__1(String dir) in C:\Projects\My\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 20
at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.<.ctor>b__1_0(AssemblyLoadContext context, AssemblyName name) in C:\Projects\My\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 19
at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at System.Reflection.RuntimeAssembly.InternalLoad(ObjectHandleOnStack assemblyName, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, RuntimeAssembly requestingAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.LoadAssembly(String assemblyName) in C:\Projects\My\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 49
--- End of inner exception stack trace ---
at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.LoadAssembly(String assemblyName) in C:\Projects\My\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line [55](https://github.com/fingers10/BlazorWasmAVPrerender/actions/runs/3374441807/jobs/5600065526#step:7:56)
at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.BuildPrerenderingOptions(CustomAssemblyLoader assemblyLoader, CommandLineOptions commandLineOptions) in C:\Projects\My\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 103
at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.Main(String[] args) in C:\Projects\My\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 28
at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.<Main>(String[] args)
Aborted (core dumped)
BlazorWasmAvPrerender GitHub Actions Link to check additional details if needed
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:22 (11 by maintainers)
Top Results From Across the Web
Blazor WASM app won't load after publish. Works fine on ...
I have now moved my project over to a WASM Blazor app since I don't really need the benefits of a server-sided application....
Read more >The "BlazorWasmAntivirusProtection.Tasks.CleanOldDlls" ...
Installed BlazorWasmAntivirusProtection version 2.0 to both server and client projects; Publish. Ran into this error:
Read more >Can not publish Blazor wasm to azure anymore
I can publish this one to a folder with no error. So my project is somehow broken...but even older code can't be published....
Read more >NuGet packages not restored on project creation
I created a new Blazor (ASP.NET Core Hosted) app using Blazor 0.5.1, which generates a solution with three projects: client, server, shared.
Read more >ASP.NET Core updates in .NET 8 Preview 1
NET 8 will enable you to use a single Blazor-based architecture ... This improves the debugging experience for apps that use NuGet packages....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@fingers10 Now the latest version of the “BlazorWasmPreRendering.Build” has supported lazy loading assemblies! 🎉
Could you check it out? and, thank you for giving me the big challenge that is adding support for lazy loading assemblies!
@jsakamoto Many thanks for your suggestions and guidance. This thread can be closed.