WebView2 Exception "The function should be called before any other API is called in 'CoreWebView2Environment' class" #4009
Replies: 3 comments
-
Hello @kentlhastings, Thanks for your inquiry! I've assigned this to a dev that might best answer your question. |
Beta Was this translation helpful? Give feedback.
-
Thanks for providing the code snippet and we will take a look into it. Currently our team is a bit short on bandwidth and will try to give an update this month. |
Beta Was this translation helpful? Give feedback.
-
The message doesn't appear to be coming from WebView2 code, and also not sure about the Browser class. @kentlhastings if this is still an issue, could you please provide the full stack of the exception? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We are using WebView2 to display html content within AutoCAD 2022. Users run an AutoCAD command to display the WebView2 UI within a WPF window. For some of our users, after the WebView2 UI is run once and then closed, upon running the command to launch again, they receive the following exception message: "The function should be called before any other API is called in 'CoreWebView2Environment' class".
Here is the code we are using to initialize the UI:

Here is the code we are using to shutdown the UI:

Any insight you could provide for how to avoid this problem would be greatly appreciated
Thank you,
Beta Was this translation helpful? Give feedback.
All reactions