.NET Webbrowser Control and Dispose()

后端 未结 3 1366
生来不讨喜
生来不讨喜 2021-01-14 01:03

I know this is a hot discussed topic with many questions and answers but I still do not find the solution for the following problem:

I have a multi-tab application.

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 01:45

    All WebBrowser instances share the session on per-process basis. According to EricLaw's answer to a similar question, it appears to be impossible to separate sessions. I'd trust Eric's statement as he worked as IE program manager at Microsoft.

    If however you'd still like to try some hacks, you may look at CoInternetGetSession. First, try saving and holding on to the returned reference to IInternetSession. Further, you could look at registering your own URL namespace (RegisterNameSpace) and implementing a pluggable protocol handler which may eventually allow to overrule this restriction.

    Of course, it sounds like an overkill and most likely won't help at all. A clean solution might be to redesign the logic to get rid of cookies and pass the state via URLs.

    EDITED: Another idea, try to navigate the WebBrowser instance to (say) "about:blank" and wait for DocumentComplete event, before actually disposing of it with Dispose().

提交回复
热议问题