Blazor issue with connecting javascript code to c# – heap is currently locked

I am quite new to blazor/ web tech, not a proper c# programmer either. I have an issue with connecting my javascript code to the c# methods. I read the documenation etc and tried few different ways but cannot get it work. I get this errror

Loaded 8.52 MB resources from cache
Debugging hotkey: Shift+Alt+D (when application has focus)
Uncaught Error Error: Assertion failed - heap is currently locked
    at Tt (localhost꞉44317/_framework/blazor.webassembly.js:1:47036)
    at invokeDotNetFromJS (localhost꞉44317/_framework/blazor.webassembly.js:1:45338)
    at invokeDotNetMethod (localhost꞉44317/_framework/blazor.webassembly.js:1:3485)
    at invokeDotNetStaticMethod (localhost꞉44317/_framework/blazor.webassembly.js:1:3241)
    at e.invokeMethod (localhost꞉44317/_framework/blazor.webassembly.js:1:1980)
    at createPostcodeFromCoordinates (<eval>/VM46947987:254:29)
    at <anonymous> (<eval>/VM46947987:6:29)

javascript side
 function createPostcodeFromCoordinates(longitude, latitude) {

    var result = DotNet.invokeMethod('cLib', 'createPostcodeFromCoordinates', longitude, latitude);
//     var postcode = this.dotNetReference.invokeMethod("createPostcodeFromCoordinates");
    // DotNet.invokeMethod('cSharpLibraries', 'createPostcodeFromCoordinates', longitude, latitude)
    //     .then(result => {
    //         console.log(result);
    //     });

C#
public static string CreatePostcodeFromCoordinates(string longitude, string latitude)
{

// Many lines of logic...

  return result;
}

Any ideas how I can fix it? This error message above with Uncaught Error Error: Assertion failed – heap is currently locked
is probably the best I managed. I was getting some other more weird messages but I think this is better! I don’t need anything async but happy to have it. Trying to keep the call as simple as possible. Plus the debugger is not working in Visual studio which may have helped to understand what goes wrong.

Thanks very much!