Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can WebView2 work in VSTO development? #353

Closed
LittleNewton opened this issue Jul 23, 2020 · 3 comments
Closed

Can WebView2 work in VSTO development? #353

LittleNewton opened this issue Jul 23, 2020 · 3 comments
Assignees

Comments

@LittleNewton
Copy link

LittleNewton commented Jul 23, 2020

Nowdays I am developing a Microsoft Word Add-in using C#. Some features in this Add-in such like code words highlighting in MS Word is difficult to implement in C#, so I decided to use JS and highlight.js.

But it looks like that webview2 does not work in VSTO dev. Even in a normal WinForm project, the demo still cannot work well. I just darg and drop a webview2 control to the main window. When I hit F5 to debug, the exception occured.

System.NullReferenceException
  HResult=0x80004003
  Message=未将对象引用设置到对象的实例。
  Source=Microsoft.Web.WebView2.WinForms
  StackTrace:
   at Microsoft.Web.WebView2.WinForms.WebView2.OnVisibleChanged(EventArgs e)

I don't know why and I just follow the guide in https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms

I need your help.

@liminzhu
Copy link
Member

I think there is some limitation with WebView2 in VSTO. This thread has more information.

#187

@LittleNewton
Copy link
Author

I think there is some limitation with WebView2 in VSTO. This thread has more information.

#187

I am sorry for hearing that.

I do believe the JS calling from VSTO is very essential for developers, espcially in Microsoft Word. Nowdays many operations such as code highlighting which looks like listings in LaTeX cannot implemented in C# easily. I hope Microsoft can enhance this module in the future.

@liminzhu
Copy link
Member

Looking back on it a bit more, we're about to make WebView loader a static lib, which probably will resolve the issue in #187.

(actually, let's close this one as a dup and discuss in 187 instead)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants