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

Could not add the 'Microsoft.Web.WebView2 0.8.230, a reference in C# windows application. #46

Closed
prasad-yadav opened this issue Sep 10, 2019 · 55 comments
Labels
feature request feature request

Comments

@prasad-yadav
Copy link

I have created the C# windows application and install Microsoft.Web.WebView2 0.8.230 dll.
The dll is installed successfully but I haven't found dll in project references.
so I have browser the dll and try to add the dll project but that dll is not added in to project?

please give me some referral answers for this issue.

@david-risney david-risney added the feature request feature request label Sep 10, 2019
@david-risney
Copy link
Contributor

david-risney commented Sep 10, 2019

Thanks for trying out our SDK! Unfortunately, the scenario you describe is not currently supported. We're working on .NET support (see #23).

We do have a TLB file in the nuget package. The closest you can get currently is to use tlbimp.exe on the TLB to generate a DLL you can use in .NET. But that won't have support for WPF or WinForms. This is what we're working on building.

@prasad-yadav
Copy link
Author

How much duration will it take to provide support for WebView2 in .NET WPF or WinForms application.

@david-risney
Copy link
Contributor

It is a feature we are planning but I'm not sure when we'll finish yet.

@afshinjafari
Copy link

afshinjafari commented Oct 14, 2019

Hi David,
Do you have any update for when this feature will be available?
also, is it possible to dllimport WebView2Loader.dll (and reference dll created using tlbimp) to create viewer control?
cheers,
Afshin

@david-risney
Copy link
Contributor

Apologies, no update on dates yet.

You could potentially use tlbimp on the tlb from the nuget package. The tlbimp generated DLL can be used to interact with the values returned from the WebView2Loader.dll CreateWebView2Environment method. But you'd likely need to make your own C# wrapper around all that to make a useful sort of WebView2 .NET control. It is doable but will be some work. This is essentially what we'll be working on to support WebView2 in .NET.

@afshinjafari
Copy link

Hi David,
Thanks for the reply,
Thant's what I'm doing right now, yes it's double but I guess worth the experience,
just one question, (sorry @prasad-yadav for hijacking the thread):
how do I provide _RemotableHandle to CreateWebView method? I guess tlbimp converted Hwnd to this structure and I'm not sure how to convert from/control handle to this structure.

@david-risney
Copy link
Contributor

Not sure offhand. I would have thought that CreateWebView should take a IntPtr as the first param for its .NET method. Perhaps this StackOverflow conversation helps.

@afshinjafari
Copy link

afshinjafari commented Oct 14, 2019

That's what I expect too, however the CreateWebView method generated by tlbimp has this _RemotableHandle as the first parameter.
The second suggestion (HWNDtoRemotableHandle method) gives me access violation exception.
so I went through and modified the wtypes.ldl then using midl generated new tlb and then with TlbImp created new type definition dll. Just successfully embedded the viewer in a winform control.
I needed to add 'library' section to WebView2.idl so it can generate a tlb file.

@landidavid
Copy link

landidavid commented Nov 29, 2019

Hello everyone, I find the WebView2 control very useful. Already successfully tested with the example WebView2Sample.

Is it possible to create a WebView2 control for UWP?

I have created an Interop.WebView2.dll from WebView2.tbl via tlbimp. I referenced the Interop.WebView2.dll in UWP and added the Microsoft.Web.WebView2 0.8.230 package via nuget.

Then I created a WebView2 class on UWP that inherits from FrameworkElement and implements IWebView2WebView, IWebView2WebView2, IWebView2WebView3, IWebView2WebView4

Now I have to implement the methods. I tried to define for example the "Navigate" method as follows:

[DllImport ("WebView2Loader.dll", EntryPoint = "Navigate")]
public static extern void Navigate (string uri);

But at runtime I get the error "System.DllNotFoundException: 'Unable to load DLL 'C:......\bin\x64\Debug\WebView2Loader.dll': Accesso negato. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

Some idea?
Thanks

@michael-russin
Copy link

WebView2Loader.dll doesn't exposes Navigate as as a method you can p/invoke. You need to create the WebView2 environment, then WebView2 browser then you can navigate. Creating the environment is p/invoke and the rest is COM interop.

You can check out some working interop code at WebView2 Interop the nuget package is here There is a .net version of the browser sample that uses the interop at DotNetBrowser sample Maybe some of that code will help.

@landidavid
Copy link

Thanks Michael for your reply.

I saw your examples and I tested WebView2 Windows Forms control which works very well. I would like to implement a WebView2 Control for a UWP but I can't do p/Invoke on WebView2Loaderdll to create the environment.

I always get an "E_ACCESSDENIED" to the DLL. Are there any limitations on the Universal Windows Platform?

@david-risney
Copy link
Contributor

We plan to support a XAML version of WebView2 that can work in UWP apps. But yes there are limitations on UWP apps that may not work well with our current WebView2Loader.

@landidavid
Copy link

I have the urgency to create in a few days a WebView 2 control for a UWP or any alternative solution that allows me to be able to use Edge-Chromium or Chome from a UWP.

Those interested can contact me privately, we agree to consult.

Thank you all

@markismail7
Copy link

markismail7 commented Dec 30, 2019

I'm currently using WebView in my .Net Application which emulates Microsoft Edge. When the update rolls out on Jan 15th 2020, Will Edge chromium replaces Microsoft Edge? If that's the case, it will be a problem for our users since we have no access to WebView2 .Net. I am little disappointed on how Microsoft left .Net behind when it comes to edge chromium. We could have contributed so much by testing it. And now the update is rolling out and yet there is no time frame on when .Net will be included. That's a set back for every company using .NET

@liminzhu
Copy link
Member

liminzhu commented Jan 6, 2020

hey @markismail7 , as far as I know on January 15th the first Stable build for Edge will be available for download, and we'll roll it out to Consumer soon after. The EdgeHTML Edge browser is getting replaced by Chromium Edge when this happens, but the actual EdgeHTML platform is still on users' machine s.t. stuff like WWA doesn't stop working.

In terms of .NET, I hear ya. It's on our roadmap for WebView2 and we're definitely not leaving .NET developers behind. It's just that the .NET support will be based on our Win32 C++ control, so from a topological order, we need to get Win32 C++ first. Don't worry, it's on the way! Internally, we're figuring out when we can get a .NET preview out for developers to test on.

@chrisjshields
Copy link

Will the Chromium Edge control support accessing the DOM tree using e.g. GetElementById as in the .Net IE WebBrowser control?

@liminzhu
Copy link
Member

liminzhu commented Jan 6, 2020

// let's open another issue if we are going talk about this extensively
// edit - looks like we can use this issue #77

Currently not planning to add native methods for DOM manipulation but you can do the same through calling scripts. Would that work for you?

@markismail7
Copy link

hey @markismail7 , as far as I know on January 15th the first Stable build for Edge will be available for download, and we'll roll it out to Consumer soon after. The EdgeHTML Edge browser is getting replaced by Chromium Edge when this happens, but the actual EdgeHTML platform is still on users' machine s.t. stuff like WWA doesn't stop working.

In terms of .NET, I hear ya. It's on our roadmap for WebView2 and we're definitely not leaving .NET developers behind. It's just that the .NET support will be based on our Win32 C++ control, so from a topological order, we need to get Win32 C++ first. Don't worry, it's on the way! Internally, we're figuring out when we can get a .NET preview out for developers to test on.

Thanks for the reply. We just need a date on when .net will be included, so we can get ready. I'm tired of using Google Chrome. Nothing against google, but i love Microsoft. The reason we needed google
chrome from the beginning is because any website that is build with Java Server pages will load slower on edge than Chrome. Everything Google uses is JSP. To me personally JSP is the slowest platform out there to build a website. Gmail is built with JSP, its takes forever to load on Chrome lol. I have 1Ghz internet speed and still takes time to load. That's why Google keep updating the splash screen for gmail lol. JSP belong in the Linux world. Thank God Amazon.com did not use JSP. And I still couldn't believe Microsoft let Google take over all those years when it comes to the internet browser. I'm excited for the edge chromium to bring the balance back. And one more thing, i pray that Microsoft is working on an Email platform so we can leave Gmail too. We've been suffering with JSP Webpages since the beginning of Google. Again i still love Google, but i need the mother of computers ( Microsoft ) to take over again.

@liminzhu
Copy link
Member

liminzhu commented Jan 8, 2020

Haha I love the passion in your reply @markismail7 .

We're currently targeting this March for a .NET preview. We (and I personally) really want to get this out ASAP but I do want to say though that there are other factors and work that can end up affecting our .NET scheduling.

@JNORMANAZ
Copy link

I've been successfully been able to use WebView2 0.8.355 in a .Net Standard C# WPF Project. I can't get it to do much, but this will work.
Reference the WebBrowser control on the form and name it.
After InitializeComponent (or another appropriate place) use the Navigate method of the WebBrowser control instance.

@markismail7
Copy link

markismail7 commented Jan 24, 2020

@JNORMANAZ Can you use invoke script? I need webview2 so bad in my project. I've been testing Edge Chrome. Microsoft finally did it. It not just meet Google Chrome, actually it exceeds it.

@michael-russin
Copy link

You can give this a try while you're waiting for the real .net WebView2 from Microsoft. .net WebView2

@JNORMANAZ
Copy link

@markismail7 I got as far as navigating!

@JNORMANAZ
Copy link

@markismail7 Yes, I could. BrowserWindowOne.NavigateToString("<script>alert('Hello world!');window.location.assign('https://www.microsoft.com');</script>");

@JNORMANAZ
Copy link

@michael-russin We may give it a try, thank you.

@rscsharma
Copy link

@michael-russin I have latest Edge Chromium installed (79.0.309.71). When I run WebView2.Wpf.Sample project, get the following exception. Any idea what might be causing this?

System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'MtrDev.WebView2.Interop.IWebView2Environment3'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D82C6A26-370F-4084-8149-C08FF1598C9B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).'

@michael-russin
Copy link

Thanks for taking a look at the sample. That sample uses Microsoft.Web.WebView2.0.8.355 which requires Edge Chromium 80. Try installing the beta version of Edge Chromium. Also please post any other questions to webview2-control

@ventodev93
Copy link

Hi,
in my team we're starting a new project and would like the new webview2-control. As its availaibilty is planned for march we're considering to use the old webview for development purposes and would like to update as soon as the new version is released.
Could you please give us a short info whether the migration from the old webview to the new one will be expensive or do we just have to change the nuget package?
Many Thanks in Advance!

@pagoe-msft
Copy link

Hi @ventodev93,

  1. By the old webview are you referring to the Edge HTML based WebView or the MS HTML based Browser Control?
  2. What flavor of WebView are you planning to use? (Win32, UWP, .NET, ...)
  3. How are you planning to use WebView in your application?

@ventodev93
Copy link

Hi @pagoe-msft,
sry - I have not been in the office in the last days so my answer is delayed.

Hi @ventodev93,

  1. By the old webview are you referring to the Edge HTML based WebView or the MS HTML based Browser Control?
    => We're using the Edge HTML based webview.
  2. What flavor of WebView are you planning to use? (Win32, UWP, .NET, ...)
    => We're building a .NET Core 3.1/.NET 5 WPF-Application
  3. How are you planning to use WebView in your application?
    => We're planning to use the WebView to host an Angular based SPA. The WPF-App handles the communication with our Hardware. So we'd like to set cookies of the Browser-Control.

Many Thanks in Advance for your Reply!

@noxo
Copy link

noxo commented Mar 12, 2020

will there be preview for UWP in March?

@applefanbois
Copy link

Our UWP project is on hold because the old UWP Webview is 10 years behind Android and iOS/macOS. We cannot move further and are waiting for UWP Webview2. It is sad that MS decided to move backward with win32 instead of moving forward like the other companies. We are now telling our customers to move to Apple products if they cannot wait a year or more until MS provide the modern tools for modern applications.

MS focusing on Win32 is telling the world : Our operating system will never be secure (sanboxed).

Our MS port will only have half of the features of our Android, iOS/macOS app. There is not even proper PDF viewer or PDF tools included in the MS SDK (the other os SDK do provide these features natively). So our Windows version will cost us thousands of dollars every year (for expensive pdf libs) just so we can provide basic PDF functionality like the other platforms.

@wjvii
Copy link

wjvii commented Apr 2, 2020

I definitely wish that Microsoft would get this new viewer control to .NET developers and also make its pdf capabilities available in the same control. I use the new Edge for both web content and PDF content including filling and signing PDFs and it would be great to have that all directly available from Microsoft "out of the box" so to speak for our .NET applications as well.

Hope we hear good news about a preview version soon.

@pagoe-msft
Copy link

@applefanbois Shipping WebView2 on UWP is very important to us. You can checkout the alpha release here: https://docs.microsoft.com/en-us/uwp/toolkits/winui3/

@wjvii Stay tuned, we will have a WebView2 .NET Preview out soon!

@noxo
Copy link

noxo commented Apr 8, 2020

@pagoe-msft it seems that WinUI3 means, that whole UWP app needs to be ported use WinUI3 Xaml components (as mixing of UWP and WinUI3 Xaml components is not supported). Are you planning to have any other paths to use WebView2 for existing UWP apps?

@wjvii
Copy link

wjvii commented Apr 8, 2020

@pagoe-msft, very exciting, looking forward to it!

One thing I ran into yesterday was the need to be able to download or at least control the download of a file from a link in the page currently shown in the Webview, which I cannot do with the current Webview, or at least could not figure out how to. It appears the old Webbrowser control did allow you to hook into the download file event if I read some of the articles correctly. Will the new WebView2 control allow me to programmatically download a file or at least hook into the event when a file is being downloaded in the browser control? I have a scenario where I need to start that in a database vs a file on disk so that would be highly useful to replace the current save to a file and then import separately.

@applefanbois
Copy link

We are doing that with the current Webview on Android, iOS and Win. but we trigger custom commands from server with javascript. We intercept and inject javascript within the Webview and obey our custom server commands to download and upload files.

@wjvii
Copy link

wjvii commented Apr 8, 2020

@applefanbois Interesting approach and sounds super flexible. I am not very guru with the javascript or Typescript but some other members of our team are. Not sure this will work for us though because it sounds like you are saying you need access to the server side to create the custom commands, which I cannot do. Did I get that right?

@applefanbois
Copy link

Yes, the server or the page loaded triggers javascript command that we intercept in our app and respond to it. We have bidirectional communication between the web page and WebView. If you need help, I can send you code. app.webview <-> webpage <-> server. Another way would be to override existing javascript function, for example to detect page name changes.

@antti-j
Copy link

antti-j commented Apr 21, 2020

Now there is new Webview2 SDK version 0.9.488. That requires Edge 84.

I didn't see any mention about WPF. Is It so that Edge 85 is the earliest possible for some preview WPF support? Or still some hope for something in Edge 84?

@applefanbois
Copy link

applefanbois commented Apr 21, 2020

All I can say is that it does not work with a pure UWP project. The programmer in charge tried and told me we got an endless list of unsolvable errors. As of now, WebView2 on UWP is just hope. Maybe Microsoft is too busy cooking something special with Marina Abramović?

@pagoe-msft
Copy link

Hi everyone,

We have released a preview of WebView2 for .NET! Check it out here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/releasenotes#09515-prerelease

@jameslin0312
Copy link

jameslin0312 commented May 20, 2020

Is there any .Net Core Getting Started Guide? By the way, in Widows form, CoreWebView2.CapturePreviewAsync has no callback handler parameter to be invoked when CapturePreview finishes writing to the stream.

@markismail7
Copy link

Hi everyone,

We have released a preview of WebView2 for .NET! Check it out here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/releasenotes#09515-prerelease

I keep getting an error on load: Anyone knows why?
NullReferenceException: Object reference not set to an instance of an object.

@antti-j
Copy link

antti-j commented May 20, 2020

I keep getting an error on load: Anyone knows why?
NullReferenceException: Object reference not set to an instance of an object.

Could the root cause be #182

@markismail7
Copy link

Hi everyone,
We have released a preview of WebView2 for .NET! Check it out here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/releasenotes#09515-prerelease

I keep getting an error on load: Anyone knows why?
NullReferenceException: Object reference not set to an instance of an object.

I tried . It didn't work. here is the error:

System.InvalidOperationException: 'An error occurred creating the form. See Exception.InnerException
for details. The error is: Object reference not set to an instance of an object.'

NullReferenceException: Object reference not set to an instance of an object.

This exception was originally thrown at this call stack:
Microsoft.Web.WebView2.WinForms.WebView2.OnVisibleChanged(System.EventArgs)
System.Windows.Forms.Control.AssignParent(System.Windows.Forms.Control)
System.Windows.Forms.Control.ControlCollection.Add(System.Windows.Forms.Control)
System.Windows.Forms.Form.ControlCollection.Add(System.Windows.Forms.Control)
Repair_.Form_test.InitializeComponent() in Form_test.Designer.vb

@ewyuen1999
Copy link

I cannot even build a simple .NET Framework 4.7.2 app with it by installing the nuget package
Microsoft.Web.WebView2 0.9.488

Severity Code Description Project File Line Suppression State
Error XLS0418 Assembly 'Microsoft.Web.WebView2.Wpf' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built. WpfWebView2 MainWindow.xaml 8



<wv2:WebView2 Name="webView"
Source="https://www.microsoft.com"
/>

Any particular things I need to do beside install the nuget?

@david-risney
Copy link
Contributor

The .NET WebView2 is first available in 0.9.515-prerelease and works with the latest Edge canary channel browser. Please make sure you're using these and if you're still hitting problems, please open a new issue. Thanks!

@markismail7
Copy link

markismail7 commented May 22, 2020

I found it lol for some reason you must change the name property. Change the Name property to webView. And it has to be the canary version. Its really fast. I love it. Can't wait for the production version.

@prasad-yadav
Copy link
Author

Hi Everyone,

When I tried to add the new webView2 control in VSTO (Word Add-In) project then it is throwing below error.

at Microsoft.Web.WebView2.WinForms.WebView2.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.AssignParent(Control value)
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at System.Windows.Forms.Form.ControlCollection.Add(Control value)
at MyRibbonAddIn.Form1.InitializeComponent() in
at MyRibbonAddIn.Form1..ctor()
at MyRibbonAddIn.MyRibbon.OnTaskPaneButton(IRibbonControl control)

I have used the below configuration.

Webview2 library: The .NET WebView2 0.9.515-prerelease
.Net Framework: 4.6.2
Visual Studio 2015
Microsoft Edge (Chromium) Canary channel
Operating system: Windows 10

@brunofrance
Copy link

Hi Everyone, I can't use WebView2 with .net core winform ; is it normal ? (it works with .net core wpf, but it's not what I use...)
Thanks

@mikemeinz
Copy link

Use NuGet package version 0.9.538-prerelease.
Do not use NuGet package version 0.9.538.

@markismail7
Copy link

markismail7 commented Jul 6, 2020

Microsoft: It has been 30 days and we still stuck with the pre-release Webview2 for windows form. We have businesses to run. Release the production version already. Thanks.

@applefanbois
Copy link

Same here our app is ready on iOS, macOS, Android... but we are stuck on Windows. We are warning our windows users that they won't get a newer version before another year. We tell them to buy Apple product if they want our latest features.

@liminzhu
Copy link
Member

liminzhu commented Jul 7, 2020

Hey folks. To set the expectation, the .NET WebView2 is targeted for EoY. There are still some major blockers until we can GA this, e.g.

  • The evergreen WebView2 installer that allows the developer to programmatically install the WebView web platform without installing the browser.
  • The .NET API itself is still new and not stable. There will potentially be some API renaming and other breaking change while we're still in preview.

https://docs.microsoft.com/en-us/microsoft-edge/webview2/roadmap

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

No branches or pull requests