Chromium Edge-based WebView2 does not work - c++

I have followed all the instructions from Getting Started with WebView2 (developer preview) to create an app that is using Microsoft Edge (Chromium). However, it is not able to find the Edge browser. I also tried the sample apps (this and this) but with the same results. I have built the apps both for 32- and 64-bit.
What I get from calling CreateWebView2EnvironmentWithDetails() is error 0x80070002, which is ERROR_FILE_NOT_FOUND (The system cannot find the file specified.)
HRESULT hr = CreateWebView2EnvironmentWithDetails(nullptr, nullptr, nullptr,
Callback<IWebView2CreateWebView2EnvironmentCompletedHandler>(
[hWnd](HRESULT result, IWebView2Environment* env) -> HRESULT {
// Create a WebView, whose parent is the main window hWnd
env->CreateWebView(hWnd, Callback<IWebView2CreateWebViewCompletedHandler>(
[hWnd](HRESULT result, IWebView2WebView* webview) -> HRESULT {
if (webview != nullptr) {
webviewWindow = webview;
}
// Resize WebView to fit the bounds of the parent window
RECT bounds;
GetClientRect(hWnd, &bounds);
webviewWindow->put_Bounds(bounds);
// Schedule an async task to navigate to Bing
webviewWindow->Navigate(L"https://www.bing.com/");
return S_OK;
}).Get());
return S_OK;
}).Get());
if (!SUCCEEDED(hr))
{
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
{
MessageBox(
nullptr,
L"Couldn't find Edge installation. "
"Do you have a version installed that's compatible with this "
"WebView2 SDK version?",
nullptr, MB_OK);
}
else
{
std::wstringstream formattedMessage;
formattedMessage << L"Failed to create webview environment"
<< ": 0x" << std::hex << std::setw(8) << hr;
MessageBox(nullptr, formattedMessage.str().c_str(), nullptr, MB_OK);
}
}
I have:
Edge Version 79.0.309.60 (Official build) beta (64-bit)
Windows 10.0.17134
Visual Studio 2019 16.4.2
Any ideas why my Edge installation is not found?

Probably the version of the Browser is not compatible with the latest version of the SDK, you may have to go back some versions for it to work, following the list:
https://learn.microsoft.com/en-us/microsoft-edge/hosting/webview2/releasenotes
Edit:
As informed by one of the developers of WebView2, at the moment WebView2 is still in preview version so always the latest version of Webview2 will accompany the latest canary version of Edge.
https://github.com/MicrosoftEdge/WebViewFeedback/issues/103#issuecomment-575287157

I got the same error, and after installed WebView2 Runtime , it works. https://developer.microsoft.com/microsoft-edge/webview2

You must install the WebView2 runtime in order to run the compatible applications.
Also, you need to upgrade the NuGet package, maybe in your code you still have the reference of "pre-release version".
In that version, "WebView2Environment" was missing it was kind of "WebView2Experiment".

Update Edge to latest version.
Update Nuget WebView2 SDK to lastest (INCLUDE prelease)

Related

Create a Direct3D12 Device fails with E_NoInterface

I'm trying to create a D3D12 device as specified in
https://msdn.microsoft.com/en-us/library/dn899120%28v=vs.85%29.aspx
I have a NVidia 670 gtx, Windows 10 preview build 9926, and last 10041 windows sdk.
I also have latest NVidia beta driver, system information for GeForce reports a DirectX12 runtime.
Calling
ID3D12Device* device;
HRESULT hr = D3D12CreateDevice(NULL, D3D_DRIVER_TYPE::D3D_DRIVER_TYPE_HARDWARE,
D3D12_CREATE_DEVICE_FLAG::D3D12_CREATE_DEVICE_NONE,
D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_11_0, D3D12_SDK_VERSION, __uuidof(ID3D12Device), (void**)&device);
Returns me a HRESULT with NOINTERFACE error code
Strangely calling:
ID3D12Object* device;
HRESULT hr = D3D12CreateDevice(NULL, D3D_DRIVER_TYPE::D3D_DRIVER_TYPE_HARDWARE,
D3D12_CREATE_DEVICE_FLAG::D3D12_CREATE_DEVICE_NONE,
D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_11_0, D3D12_SDK_VERSION, __uuidof(ID3D12Object), (void**)&device);
returns me a valid object, but I'm not able to use QueryInterface to get a valid device object afterwards.
Please note I already tried using LoadLibrary/GetProcAddress instead of using d3d12 headers, which returns same error code.
You should always use the same OS and SDK Build, because APIs can change betweens builds. Because you use SDK for Build 10041, you should also update Windows 10 to the Build 10041. Open the Settings App, and search for a new Windows 10 Build and install it.

Error when instantiating ADODB ConnectionPtr on Windows Server 2008

I have an application that I have compiled on Windows 7 64-bit. It works fine on that PC, but I am now trying to get it to work on Windows Server 2008 R2 Standard.
Whenever I try and instantiate ADODB::Connection, I receive the following error:
HRESULT : No such interface supported; hr=0x80004002
Code that generates the error is below:
CoInitialize(NULL);
_ConnectionPtr link;
link.CreateInstance(__uuidof(Connection) );
if (link == NULL) {
_com_error err(hr);
Error(err);
}
Now I found this thread: http://social.msdn.microsoft.com/Forums/vstudio/en-US/12c95ba7-60ed-4303-b4da-e811150b8d13/cannot-able-to-instance-adodbconnection-in-2008-r2-server-core-no-such-interface-supported?forum=vcgeneral, which seems to suggest the problem with a particular windows update, and provides a fix for it. However, the update that supposedly causes the problems is not on this machine, and if I try to install the fix I simply get an error saying that the update "does not apply to this computer".
Any ideas anyone? Thanks in advance.

ADO objects instance creation failed on the target computer

I created an MFC application using VC++ 6.0 on my development computer installing Windows XP SP3. In this application, I used ADO objects to access SQL database server :
CoInitialize (NULL);
try
{
_ConnectionPtr pConn;
HRESULT hr = pConn.CreateInstance (__uuidof (Connection));
if (FAILED (hr))
{
AfxMessageBox ("Can't create intance of Connection");
}
//...
}
//...
Of course, the app works fine on my computer. However, I copied the whole Release folder of the app and then run it on another computer with Windows XP SP3 installed, the app failed at creating the Connection object with hr = -2147467262.
I searched on the internet much but don't see any resolution.
Does anyone know this issue and could you give me some guides on that?

CSIDL constant for user folder for Windows XP

I can't seem to find what is the CSIDL constant for "C:\Documents and Settings\username" folder for Windows XP?
EDIT: I'm retrieving this path using the following code:
HANDLE hUserToken = NULL;
if(WTSQueryUserToken(dwUserSessionID, &hUserToken))
{
PIDLIST_ABSOLUTE pIdl = NULL;
if(SHGetFolderLocation(NULL, nCSIDL, hUserToken, NULL, &pIdl) == S_OK)
{
SHGetPathFromIDList(pIdl, path_buf);
ILFree(pIdl);
}
CloseHandle(hUserToken);
}
The issue becomes that the code returns C:\WINDOWS\system32\config\systemprofile for an administrative account when I'm expecting C:\Documents and Settings\Administrator.
Check this reference: http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx
The constant you are looking for is CSIDL_PROFILE.
Code snippet to obtain locations: ConstantSpecialItems.cpp + binary ConstantSpecialItems.exe if you want to print them yourself
Sample Locations:
Windows XP
Windows Vista
Windows 7
The one you ask for:
Windows version 5.1, Build 2600
CSIDL paths:
[...]
CSIDL_PROFILE: C:\Documents and Settings\John Doe

OLE/COM Object Viewer reports STG_E_FILENOTFOUND

I have created simple COM DLL using ATL and have added "ATL Simple Object" after that. To be sure server is registering I have placed messagebox:
STDAPI DllRegisterServer(void)
{
MessageBoxA ( NULL, "Hello World!", "Test", MB_OK );
HRESULT hr = _AtlModule.DllRegisterServer();
return hr;
}
Registering does fine. I decided to look how this object looks with OLE-COM Object Viewer that is part of SDK. Viewer reports error:
"LoadTypelib'(c:\pr\ILight.dll) failed.
<No system message defined> STG_E_FILENOTFOUND ($800300002)
Does it means my COM dll corrupted? How to make VIewer to show my dll information?
P.S.
Project RC file contians:
"REGISTRY"
IDR_ILIGHT
HKCR{}
IDR_LIGHT
HKCR
{
AboutiLight.1 = s 'Light Class'
{
CLSID = s '{DBC53EA8-A51E-4374-B104-06A834273B0C}'
}
AboutiLight = s 'Light Class'
{
CurVer = s 'AboutiLight.1'
}
NoRemove CLSID
{
ForceRemove {DBC53EA8-A51E-4374-B104-06A834273B0C} = s 'Light Class'
{
ProgID = s 'AboutiLight.1'
VersionIndependentProgID = s 'AboutiLight'
ForceRemove Programmable
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
TypeLib = s '{1D9F859D-10FF-4827-A341-4A8B8E318A61}'
Version = s '1.0'
}
}
}
String table
String table
ID=IDS_PROJNAME Value=100 Caption ILight
Version
VS_VERSION_INFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEMASK 0x3fL
FILEFLAGS 0x0L
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
After having received the same error (STG_E_FILENOTFOUND), and seeing Joe Willcoxson's comment about 64-bit and 32-bit, I was able to find a solution.
If you are using OleView.exe, the OLE/COM Object Viewer, there are actually two versions of it: 32-bit, and 64-bit. Ensure that you are launching with the proper version of OleView. The version in the base "BIN" folder of the SDK will be the 32-bit version. The "x64" folder will have the 64-bit version of the application, which is not fully compatible with older binaries and their typelibs (made in a 32-bit world).
On the other hand, if your new DLL is actively being compiled for x64, then it's highly likely 32-bit OleView will not be able to read the data properly, either.
1) Check to make sure that is the right path to your DLL.
2) Open the DLL itself from Visual Studio and check to be sure that a type library is embedded in the resources. If a typelib isn't found, add one.
3) If all that fails, did you register it under an administrator account/shell. If you call regsvr32.exe on it, make sure you are running with elevated privileges.