Unhandled Exception When opening PDF

I am using the Syncfusion.Blazor.PDFViewerServer nuGet package and am having an issue with opening a pdf file. Every time I get an error as per the below :-

Error: Microsoft.JSInterop.JSException: Could not find 'sfBlazor.throwError' ('throwError' was undefined).

Error: Could not find 'sfBlazor.throwError' ('throwError' was undefined).

    at https://localhost:44392/_framework/blazor.server.js:1:67714

    at Array.forEach (<anonymous>)

    at e.findFunction (https://localhost:44392/_framework/blazor.server.js:1:67674)

    at v (https://localhost:44392/_framework/blazor.server.js:1:69416)

    at https://localhost:44392/_framework/blazor.server.js:1:70362

    at new Promise (<anonymous>)

    at e.beginInvokeJSFromDotNet (https://localhost:44392/_framework/blazor.server.js:1:70335)

    at https://localhost:44392/_framework/blazor.server.js:1:26442

    at Array.forEach (<anonymous>)

    at e.invokeClientMethod (https://localhost:44392/_framework/blazor.server.js:1:26412)

   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)

   at Syncfusion.Blazor.Internal.SyncfusionInterop.Init[T](IJSRuntime jsRuntime, String elementId, Object model, String[] events, String nameSpace, DotNetObjectReference`1 helper, String bindableProps, Dictionary`2 htmlAttributes, Dictionary`2 templateRefs, DotNetObjectReference`1 adaptor, String localeText)

   at Syncfusion.Blazor.BaseComponent.OnInitRenderAsync()

   at Syncfusion.Blazor.BaseComponent.InitComponent()

   at Syncfusion.Blazor.BaseComponent.OnAfterRenderAsync(Boolean firstRender)

   at Syncfusion.Blazor.PdfViewer.PdfViewerBase.OnAfterRenderAsync(Boolean firstRender)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)


I have attached a sample solution that generates the error. I cannot get to the bottom of the error?


Attachment: WebApplication1_dae9c73b.zip

1 Reply

DM Dhivyabharathi Mohan Syncfusion Team February 21, 2022 03:48 AM UTC

Hi Richard, 

 
We have checked with the provided details and found that the reported issue is due to the PDF Viewer script is not referred properly while using the script isolation. To resolve this problem, we suggest you use the PDF Viewer script in the _Host.cshtml file.
 
_Host.html
 

 

 
Instead of CDN reference, you can also directly refer to the PDF Viewer script by downloading it from the following link,  

 
Startup.cs
 
  
public void ConfigureServices(IServiceCollection services)  
{  
      services.AddRazorPages();  
  
      services.AddSyncfusionBlazor(option => { option.IgnoreScriptIsolation = true; });  
     services.AddServerSideBlazor();  
     services.AddSingleton<WeatherForecastService>();  
      services.AddServerSideBlazor().AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; });  
} 

 
For more information, kindly refer to the following link,  

 
Kindly try this and let us know if the issue resolves or not. 
  
Regards, 
Dhivya. 


Loader.
Up arrow icon