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

WUApi error -> System.InvalidCastException : Specified cast is not valid. #496

Open
MacKey-255 opened this issue Dec 2, 2024 · 0 comments

Comments

@MacKey-255
Copy link

Hello. I run the test WUApiTests.TestInstaller and it throws:

System.InvalidCastException : Specified cast is not valid.
   at System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
   at Vanara.PInvoke.WUApi.IUpdateDownloader.set_Updates(IUpdateCollection value)
   at Vanara.WindowsUpdate.UpdateDownloader..ctor(IEnumerable`1 updates) in C:\...\RiderProjects\Vanara\WindowsUpdate\WindowsUpdate.cs:line 1618
   at Vanara.PInvoke.Tests.WUApiTests.TestInstaller() in C:\...\RiderProjects\Vanara\UnitTests\PInvoke\WUApi\WUApiTests.cs:line 72

The method set_Updates on IUpdateDownloader from Vanara.PInvoke.WUApi causing the issue.

I test it code and give me the same error:

// Create Downloader
var session = new IUpdateSession();
var downloader = session.CreateUpdateDownloader();
var updatesToDownload = new IUpdateCollection();
// ... add or not some Updates on updatesToDownload collection
downloader.Updates = updatesToDownload; // <------ issue

SAlu2s

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

1 participant