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

Generated Wrapper calls Marshal.GetNativeVariantForObject which is not supported #82

Open
zznty opened this issue Jun 24, 2024 · 3 comments

Comments

@zznty
Copy link

zznty commented Jun 24, 2024

I was working with WebView2 COM wrappers and encountered an issue where calling CoreWebView2.AddHostObjectToScript which produces the following output

System.NotSupportedException: Built-in COM has been disabled via a feature switch. See https://aka.ms/dotnet-illink/com for more information.
   at System.Runtime.InteropServices.Marshal.GetNativeVariantForObject(Object obj, IntPtr pDstNativeVariant)
   at WinFormsComInterop.WebView2.ICoreWebView2Wrapper.webview2::Microsoft.Web.WebView2.Core.Raw.ICoreWebView2.AddHostObjectToScript(String name, Object& object)
   at Microsoft.Web.WebView2.Core.CoreWebView2.AddHostObjectToScript(String name, Object rawObject)

I assume COM wrappers source generator unintentionally emits a call into this method instead of using ComWrappers-specific code.

@kant2002
Copy link
Owner

I’m not sure that
A) you are using correct ComWrappers instance and
B) I have support only for Net 7. Have to finish interface implementation for Net 8 which is tiresome

can you tell me what TFM are you targeting? And how do you enable ComWrappers?

@zznty
Copy link
Author

zznty commented Jun 25, 2024

Looks like I was targeting net 8 as it has somewhat working built-in ComWrappers source generator. Probably would have to wait for you to add support of net 8.

@zznty
Copy link
Author

zznty commented Jul 3, 2024

An update for this issue. I had to write a source generator for IDispatch COM interface implementation and to get around that exception from Marshal.GetNativeVariantForObject, call ICoreWebView2 directly.

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