-
Notifications
You must be signed in to change notification settings - Fork 87
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
Calling IMMDevice.Activate()
results in a NullReferenceException
#1081
Comments
I hit this as well. The nullable Poking @AArnott for prioritization 😅 |
I don't think there's anything wrong with calling I suspect the issue is that the .NET interop layer cannot handle a null reference passed into an But on the flip side, I don't know why CsWin32 is generating the COM interface with an |
This bug was surprisingly difficult to solve. |
Yay, thanks @AArnott. Will try it out tonight. |
Actual behavior
Calling the
IMMDevice.Activate()
overload with the convenience extension (e.g. the one that takes aGuid
rather than aGuid*
) method results in aNullReferenceExcception
.It seems the issue is in the generated convenience extension method that looks like this:
The actual culprit is the
Unsafe.NullRef<PROPVARIANT>()
call--it seems that passing a non-nullable struct type to it results in aNullReferenceException
.Expected behavior
Calling the
.Activate()
convenience overload works!Repro steps
NativeMethods.txt
content:NativeMethods.json
content (if present):N/A
Any of your own code that should be shared?
Here's a little minimal sample, cut down a bit from what I have:
Context
Note: this is a WPF project.
0.3.49-beta
net7.0-windows
LangVersion
(if explicitly set by project): [e.g.9
]: Not explicitly setThe text was updated successfully, but these errors were encountered: