Skip to content

Cannot marshal 'parameter #2': Invalid managed/unmanaged type combination (Interfaces must be paired with Interface) #530

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

Closed
shane-vorwerk opened this issue Apr 18, 2025 · 2 comments

Comments

@shane-vorwerk
Copy link

Using the following code I seem to be running into a problem with the call to GetPropertyStore:

Image

I get the error Invalid managed/unmanaged type combination (Interfaces must be paired with Interface). Either I am declaring the ICreateObject incorrectly or there is a bug in GetPropertyStore which is causing the exception to be thrown.

What is the best way to correct this?

@dahall
Copy link
Owner

dahall commented Apr 18, 2025

You found a bug in the declaration of IPropertyStoreFactory.GetPropertyStore, which I have now corrected. Thank you.

First question: Have you seen the wrapper classes in Vanara.Windows.Shell.Common? They make working with shell items and properties much simpler.

Second question: Are you aware of the overloaded methods that can make your code a little simpler?

var propertyStoreFactoryForChild = pFolder.BindToObject<IPropertyStoreFactory>(item)!;
propertyStoreFactoryForChild!.GetPropertyStore(GETPROPERTYSTOREFLAGS.GPS_DEFAULT, null, typeof(IPropertyStore).GUID, out var propertyStoreForChild);

@dahall dahall closed this as completed Apr 18, 2025
@shane-vorwerk
Copy link
Author

Hi, thanks for fixing this. I am translating some C++ code so I am keeping the C# as close as possible to that so I can make sure it is correctly translated.

Thanks also for pointing out the overloaded methods, I was not aware of them.

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