question

PriyankaSongra-6960 avatar image
0 Votes"
PriyankaSongra-6960 asked JiachenLiMFST-9349 commented

Exception when trying to use AddOrUpdateCookie(CoreWebView2Cookie cookie) to set cookies in WebView2

I am getting the following exceptions while updating the cookies.

COM object that has been separated from its underlying RCW cannot be used.
at System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2CookieManager.AddOrUpdateCookie(ICoreWebView2Cookie cookie)
at Microsoft.Web.WebView2.Core.CoreWebView2CookieManager.AddOrUpdateCookie(CoreWebView2Cookie cookie)
at oracle.apps.projects.foundation.integration.msp.client.pageflow.PageFlowRequest.WebView2_CoreWebView2InitializationCompleted(Object sender, CoreWebView2InitializationCompletedEventArgs e)

We are initializing the ADF session in an independent thread (STA) and storing the cookies in a context object.
Later, we are getting the above exception when we try to update the cookies using AddOrUpdateCookie in another thread (our main thread) which invokes our functional flow.

The above exception is not observed when both login and navigate actions are performed in the same thread. Also, session information is persisted across requests.

Any pointers on how to avoid the above exception with multi thread model?

Thanks,
Priyanka

dotnet-visual-basicwindows-embedded
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @PriyankaSongra-6960 ,
It is recommended to post your problem on WebView2Feedback Issues on github.


0 Votes 0 ·

0 Answers