ant-design-blazor / ant-design-charts-blazor

A Blazor chart library, based on G2Plot
https://ant-design-blazor.github.io/ant-design-charts-blazor/
Apache License 2.0
172 stars 39 forks source link

Could not find 'AntDesignCharts.interop.create' #121

Open CoolDaddyCool opened 1 year ago

CoolDaddyCool commented 1 year ago

Hello,

I'm new to AntDesignCharts. I'm getting the below exception, when Blazor is loaded for the first time locally:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Could not find 'AntDesignCharts.interop.create' ('AntDesignCharts' was undefined). Error: Could not find 'AntDesignCharts.interop.create' ('AntDesignCharts' was undefined). at https://localhost:7086/_framework/blazor.webassembly.js:1:328 at Array.forEach () at a.findFunction (https://localhost:7086/_framework/blazor.webassembly.js:1:296) at _ (https://localhost:7086/_framework/blazor.webassembly.js:1:2437) at https://localhost:7086/_framework/blazor.webassembly.js:1:3325 at new Promise () at Object.beginInvokeJSFromDotNet (https://localhost:7086/_framework/blazor.webassembly.js:1:3306) at Object.St [as invokeJSFromDotNet] (https://localhost:7086/_framework/blazor.webassembly.js:1:59960) at _mono_wasm_invoke_js_blazor (https://localhost:7086/_framework/dotnet.6.0.15.94lmhaqvb3.js:1:195300) at wasm://wasm/00971dfa:wasm-function[219]:0x1a4c1 Microsoft.JSInterop.JSException: Could not find 'AntDesignCharts.interop.create' ('AntDesignCharts' was undefined). Error: Could not find 'AntDesignCharts.interop.create' ('AntDesignCharts' was undefined). at https://localhost:7086/_framework/blazor.webassembly.js:1:328 at Array.forEach () at a.findFunction (https://localhost:7086/_framework/blazor.webassembly.js:1:296) at _ (https://localhost:7086/_framework/blazor.webassembly.js:1:2437) at https://localhost:7086/_framework/blazor.webassembly.js:1:3325 at new Promise () at Object.beginInvokeJSFromDotNet (https://localhost:7086/_framework/blazor.webassembly.js:1:3306) at Object.St [as invokeJSFromDotNet] (https://localhost:7086/_framework/blazor.webassembly.js:1:59960) at _mono_wasm_invoke_js_blazor (https://localhost:7086/_framework/dotnet.6.0.15.94lmhaqvb3.js:1:195300) at wasm://wasm/00971dfa:wasm-function[219]:0x1a4c1 at Microsoft.JSInterop.JSRuntime.d161[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at AntDesign.Charts.ChartComponentBase1.d58[[AntDesign.Charts.LineConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at AntDesign.Charts.ChartComponentBase`1.d_55[[AntDesign.Charts.LineConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) window.Module.s.printErr @ blazor.webassembly.js:1 :62784/24f264e093ae48e98b6d1106a8ba0c18/browserLinkSignalR/negotiate?requestUrl=https%3A%2F%2Flocalhost%3A7086%2F&browserName=&userAgent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML%2C+like+Gecko)+Chrome%2F111.0.0.0+Safari%2F537.36+Edg%2F111.0.1661.43&browserIdKey=window.browserLink.initializationData.browserId&browserId=e3d2-acc5&clientProtocol=1.3&=1682241155555:1

   Failed to load resource: net::ERR_CONNECTION_REFUSED

:62784/24f264e093ae48e98b6d1106a8ba0c18/browserLinkSignalR/negotiate?requestUrl=https%3A%2F%2Flocalhost%3A7086%2F&browserName=&userAgent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML%2C+like+Gecko)+Chrome%2F111.0.0.0+Safari%2F537.36+Edg%2F111.0.1661.43&browserIdKey=window.browserLink.initializationData.browserId&browserId=778b-7654&clientProtocol=1.3&_=1682241157950:1 Failed to load resource: net::ERR_CONNECTION_REFUSED

When I refresh the browser, exception disappeared and app woks fine. But when I restart the application I'm getting the same error. I have tried to clear the cache but that did not work for me. I have also deployed my app to Azure Static Web app and I got the same error. Thanks

SvdSinner commented 1 year ago

Similar issue here. I tryied to copy a gauge from AntDesign.Charts.Docs\Demos\Gauge\Gauge_chart into my application and am receiving: Microsoft.JSInterop.JSException: Could not find 'AntDesignCharts.interop.create' ('AntDesignCharts' was undefined). Error: Could not find 'AntDesignCharts.interop.create' ('AntDesignCharts' was undefined). at https://localhost:7213/_framework/blazor.webassembly.js:1:328 at Array.forEach () at a.findFunction (https://localhost:7213/_framework/blazor.webassembly.js:1:296) at _ (https://localhost:7213/_framework/blazor.webassembly.js:1:2442) at https://localhost:7213/_framework/blazor.webassembly.js:1:3330 at new Promise () at Object.beginInvokeJSFromDotNet (https://localhost:7213/_framework/blazor.webassembly.js:1:3311) at Object.Gt [as invokeJSFromDotNet] (https://localhost:7213/_framework/blazor.webassembly.js:1:62569) at Object.Ii (https://localhost:7213/_framework/dotnet.7.0.5.th7mlzo7or.js:5:71974) at _mono_wasm_invoke_js_blazor (https://localhost:7213/_framework/dotnet.7.0.5.th7mlzo7or.js:14:103886) at Microsoft.JSInterop.JSRuntime.d161[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at AntDesign.Charts.ChartComponentBase1.d58[[AntDesign.Charts.GaugeConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at AntDesign.Charts.ChartComponentBase`1.d__55[[AntDesign.Charts.GaugeConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

superjerry88 commented 1 year ago

Make sure the JS static file is linked in your wwwroot/index.html (WebAssembly) or Pages/_Host.razor (Server)

<script src="https://unpkg.com/@antv/g2plot@latest/dist/g2plot.min.js"></script>
<script src="_content/AntDesign.Charts/ant-design-charts-blazor.js"></script>
cdpp1996 commented 9 months ago

You need to determine if the referenced js is in the correct location