CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

XAML islands in a classic win32 dll is it possible? Error: hresult_no_interface at memory #252

Closed robertsi closed 4 years ago

robertsi commented 4 years ago

Hi!

I tried to create a standard win32.dll that creates a win32 thread+ window and uses xaml islands.

I debugged the dll....and it fails on auto interop = desktopSource.as<IDesktopWindowXamlSourceNative>(); with error hresult_no_interface at memory.

image

KR, Robert

ghost commented 4 years ago

Hello robertsi, thank you for your interest in Win32!

I have automatically added a "needs triage" label to help get things started. Our team will look into the question and answer ASAP. Other community members may also answer the question and provide feedback 🙌

robertsi commented 4 years ago

Well had to comment out #define WIN32_LEAN_AND_MEAN in framework.h. Should have been mentioned in "Host a standard UWP control in a C++ Win32 app"!!! Code there just happens to work because it deletes the framework.h include...

In general WinRT tooling in 16.5.3 is a headache atm, especially with the usercontrol, viewmodel grouping bug (https://developercommunity.visualstudio.com/content/problem/959456/item-template-dependent-nesting-behavior-broken-in.html) ...almost unusable unless you look at github samples and maually edit vcxproj file. Otherwise it was not generating the .idl, .h and .cpp files for new user controls. tool was randomly renaming them to xaml.h and xaml.cpp and also not generating stubs for idl files, and generating stubs for already deleted .idl files). This needs a fix yesterday!

azchohfi commented 4 years ago

@robertsi I'm sorry you had a bad experience with our docs. @marb2000 can you take a look at these to update the docs?

robertsi commented 4 years ago

@azchohfi Well It is mentioned in Host a custom UWP control in a C++ Win32 app(https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/host-custom-control-with-xaml-islands-cpp), but as I was first trying to get the basics working I was unnecessary scratching my head for a few hours. But a far bigger issue was that the wizards for adding items are not working!

Following wizards: image

produces almost nothing and mess project up. image Event viewmodel.idl is not picked up as it generates nothing, then I have to fix it all by manually editing .vcxproj project files, looking at examples in github...I also tried to do a complete uninstall/reinstall of visual studio 16.5.3....result is the same...

KR, Robert

marb2000 commented 4 years ago

It's a Visual Studio regression in C++/WinRT. I have informed them, waiting for a response.

ghost commented 4 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

MikeWeller commented 4 years ago

I just ran into this while trying the example on https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/host-standard-control-with-xaml-islands-cpp based on a new project using the "Windows Desktop Application" C++/WinRT template.

As above, I worked around it by adding #undef WIN32_LEAN_AND_MEAN at the top of the .pch in the project. Thanks @robertsi !

ghost commented 4 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 4 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 4 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 4 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 4 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 4 years ago

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

marb2000 commented 4 years ago

It seems that #undef WIN32_LEAN_AND_MEAN was causing this issue. We updated the doc: https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/host-custom-control-with-xaml-islands-cpp