A Blazor app ships, obfuscated, and a button that worked all through development now fails in production:
Microsoft.JSInterop.JSException: The assembly 'MyApp' does not contain a public invokable method with [JSInvokable("ComputeTotal")].
Enter fullscreen mode
Exit fullscreen mode
The method is still there. It is still public . It still carries [JSInvokable] . The call still works in an un-obfuscated build. The only thing that changed is that a renaming pass turned ComputeTotal into a . That one rename broke a contract that lives half in .NET and half in a JavaScript string literal β and the fix tells you something precise about where Blazor keeps the name it matches against.
The real question
JavaScript calls into .NET by name :
const total = await DotNet . invokeMethodAsync ( 'MyApp' , 'ComputeTotal' , [ 1 , 2 , 3 ] ) ;
Enter fullscreen mode
Exit fullscreen mode
Two strings cross the boundary: the assembly's simple name and a method identifier .β¦