-
Notifications
You must be signed in to change notification settings - Fork 51
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 be used inside a Dll? #3240
Comments
Thanks for reaching out. I've assigned this to a dev that can best answer your question. |
If you include |
I added #include <dcomp.h> to framework.h.
The file that gives the error when compiling is pch.cpp. The error occurs
with and without <dcomp.h>.
The error has not changed:
1>pch.cpp
1>c:\chrm9\manmaps\packages\microsoft.windows.implementationlibrary.1.0.230202.1\include\wil\resource.h(2550):
error C2440: 'specialization': cannot convert from 'void (__stdcall
*)(HANDLE) noexcept' to 'unknown-type'
1>c:\chrm9\manmaps\packages\microsoft.windows.implementationlibrary.1.0.230202.1\include\wil\resource.h(2550):
note: Context does not allow for disambiguation of overloaded function
1>Done building project "ManMaps.vcxproj" -- FAILED.
=
The framework.h file is attached.
Thanks,
Mark
Mark W. Eltgroth, PhD
CHARM® Software
Mark Eltgroth LLC
http://www.CharmModel.com
6455 County Road 2600
Lometa, TX 76853-4028
Mobile: 512.626.0245
***@***.***
***@***.***
On Mon, Feb 27, 2023 at 2:14 PM Liang Zhao - MSFT ***@***.***> wrote:
If you include <dcomp.h>, IDCompositionDevice should be defined.
HelloWebView.cpp does not use IDCompositionDevice. Which file that has
IDCompositionDevice and failed to build?
—
Reply to this email directly, view it on GitHub
<#3240 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6DUCGJXMZLW6LRMERRZ7SLWZUDLJANCNFSM6AAAAAAVHR7QQY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
#pragma once
/*
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
//#include "WinSDKVer.h"
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h> // MFC OLE classes
#include <afxodlgs.h> // MFC OLE dialog classes
#include <afxdisp.h> // MFC Automation classes
#endif // _AFX_NO_OLE_SUPPORT
#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h> // MFC ODBC database classes
#endif // _AFX_NO_DB_SUPPORT
#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h> // MFC DAO database classes
#endif // _AFX_NO_DAO_SUPPORT
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
*/
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
//#define NTDDI_VERSION 0x06030000
#include <SDKDDKVer.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <WinUser.h>
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#include <dcomp.h>
#include <wil/com.h>
#include <wrl.h>
#include "WebView2EnvironmentOptions.h"
#include "WebView2.h"
|
Is this the same issue as #1840? |
There is also similar feedback in MicrosoftEdge/WebView2Samples#108. |
The errors changed but, in general, neither of those issues helped. I had
already commented out those lines. I am using an earlier version of wil
(1.0.190930.1). When I upgraded my original erro went away but there were a
number of others that appeared.
I found a way around the problem by modifying the sample code and accessing
it through SendMessage and PostMessage. It's a bit of a kluge but
appears to be doing what I need.
I will revisit webView2 in dlls in the future when webView2 has had time to
mature.
Sincerely,
Mark
Mark W. Eltgroth, PhD
CHARM® Software
Mark Eltgroth LLC
http://www.CharmModel.com
6455 County Road 2600
Lometa, TX 76853-4028
Mobile: 512.626.0245
***@***.***
***@***.***
…On Mon, Feb 27, 2023 at 6:01 PM Liang Zhao - MSFT ***@***.***> wrote:
There is also similar feedback in MicrosoftEdge/WebView2Samples#108
<MicrosoftEdge/WebView2Samples#108>.
—
Reply to this email directly, view it on GitHub
<#3240 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6DUCGP6DNQX2OCR2PLQQLDWZU555ANCNFSM6AAAAAAVHR7QQY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
See microsoft/wil#25 and microsoft/wil#272 and microsoft/wil#302 |
As a work-around, downgrade the NuGet package Microsoft.Windows.ImplementationLibrary to 1.0.210803.1. |
Rami,
Thanks. Downgrading removed the error.
However, the workaround that I used was to make the dll into an exe. Then
the code that needed the one method uses CreateProcess to run the exe. All
communication is then done using PostMessage and SendMessage. That appears
to work fine and uses the latest NuGet libraries. An added plus is that the
new process is its own thread which helps resolving some timing issues.
…On Thu, Mar 23, 2023 at 8:15 PM Rami ***@***.***> wrote:
As a work-around, downgrade the NuGet package
Microsoft.Windows.ImplementationLibrary to 1.0.210803.1.
—
Reply to this email directly, view it on GitHub
<#3240 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6DUCGIAM4VCDOO7JWOFNTLW5TYTNANCNFSM6AAAAAAVHR7QQY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Tested the WebView2GettingStarted project. Worked fine. Created a MFC Dll and copied the HelloWebView.cpp file and added it to the Dll project. Renamed WinMain to something else. Installed the packages from NuGet.
When the Dll is compiled, I get the error:
Error C2440 'specialization': cannot convert from 'void (__stdcall *)(HANDLE) noexcept' to 'unknown-type' WebView2Dll c:\temp\webview2dll\packages\microsoft.windows.implementationlibrary.1.0.230202.1\include\wil\resource.h 2550
Any suggestions on an option setting or something else to fix the problem?
I modified WINAPI_FAMILY to WINAPI_PARTITION_DESKTOP and got rid of that problem but other parameters (e.g. IDCompositionDevice)were not being defined.
The text was updated successfully, but these errors were encountered: