-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Imaging.CreateBitmapSourceFromHIcon crash: Value does not fall within the expected range. #10397
Comments
Well spotted! |
Are you interested in creating a PR with a fix? |
I am unable to find |
Line 22 in 43f4bc5
|
(you can search for InteropBitmap here on GitHub) |
I cloned the repo and opened it in VS. Now it is much easier. I have mocked up a solution: n9@623fc97, but I do not know, how to test it. (I don't have much experience with WPF or its internals.) |
That's a good start. I don't think you need the empty rectangle check, because the GetScaledWidthAndHeight method takes care of the case. There is a guide at https://github.com/dotnet/wpf/blob/main/Documentation/developer-guide.md though it doesn't look very friendly to me. You can try to run |
If you mean this condition: I do not understand, how
I rebased the branch (commit) on the release/9.0 branch.
It failed:
|
That started like two weeks ago; using VS Developer prompt and running the build from there should work just fine though. Or you can just build it directly if you use the |
the msvcurtd_netcore.lib is part of the MSVC, perhaps you are missing some of the components of VS from the developer guide? |
I would suggest you import the https://github.com/dotnet/wpf/blob/main/Documentation/wpf.vsconfig into the VS installer. If I had to take a guess, it would be the C++/CLI support. GitHub will probably build it but not test it. It is a good practice (and PR acceptance criteria) to make sure your changes compile and do what you expect. |
@n9 Looks like you are working on this issue, hence assigning it to you. |
Alright, so from my binlogs: When building via dev prompt (that works), the linker command used is:
When building via standard command line (which fails), the linker command line is:
So yeah, as we during local build just use whatever is currently set in the environment for MSVC (where the latest installation of whatever update on Visual Studio always overrides), my environment was overriden by my latest Preview installation and that was missing So @n9 looking at your screenshot, please install |
@n9 are you still planning to raise your PR? If not, I'm happy to do it. |
@h3xds1nz Unfortunately, I don't have much time at the moment to create a PR. (Feel free to use my commit: n9@cc849d5.) |
Description
Imaging.CreateBitmapSourceFromHIcon
, when called withBitmapSizeOptions.FromHeight(16)
, throws ArgumentException: Value does not fall within the expected range.Reproduction Steps
Expected behavior
The above code will not throw an exception.
Actual behavior
The code above throws ArgumentException: Value does not fall within the expected range.
Regression?
It does not seem to be.
Known Workarounds
Do not use
Imaging.CreateBitmapSourceFromHIcon
with explicitBitmapSizeOptions
.Impact
Any API that uses
InteropBitmap
with explicitBitmapSizeOptions
may be affected.Configuration
.NET 9 / Win10 / x64
It may not, as the problem is in the managed code.
Other information
The problem seems to be caused by the
InteropBitmap.FinalizeCreation
method that calls:I assume that the first two arguments of
BitmapSizeOptions.GetScaledWidthAndHeight
should contain the original image size instead of_sizeOptions.PixelWidth
and_sizeOptions.PixelHeight
.The text was updated successfully, but these errors were encountered: