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

Could not load type 'PhotoSauce.MagicScaler.Converters.ChannelChanger`1' #125

Closed
hheexx opened this issue Oct 14, 2023 · 8 comments
Closed

Comments

@hheexx
Copy link

hheexx commented Oct 14, 2023

After updating to 0.14 (dotnet 7 on linux):

System.TypeLoadException

Could not load type 'PhotoSauce.MagicScaler.Converters.ChannelChanger`1' from assembly 'PhotoSauce.MagicScaler, Version=0.14.0.0, Culture=neutral, PublicKeyToken=fc6b9b7b06809481'.

@saucecontrol
Copy link
Owner

That type was renamed in 4a5048a, but it was internal and is no longer referenced anywhere in my code.

I'd guess either you've got a mismatched codec assembly version (NuGet dependencies should prevent that) or you've got something using it through reflection (in which case you get what you get).

@hheexx
Copy link
Author

hheexx commented Oct 14, 2023

I'm not using any reflation related to this library, just resizing large number of images from web....

@hheexx
Copy link
Author

hheexx commented Oct 14, 2023

Here is stack:

System.TypeLoadException: Could not load type 'PhotoSauce.MagicScaler.Converters.ChannelChanger`1' from assembly 'PhotoSauce.MagicScaler, Version=0.14.0.0, Culture=neutral, PublicKeyToken=fc6b9b7b06809481'.
?, in void PngEncoder.writeHeader(int pngfmt, int width, int height, IPixelSource src, IMetadataSource meta)
?, in void PngEncoder.WriteFrame(IPixelSource source, IMetadataSource metadata, Rectangle sourceArea)
?, in ProcessImageResult MagicImageProcessor.WriteOutput(PipelineContext ctx, Stream ostm)
?, in ProcessImageResult MagicImageProcessor.ProcessImage(Stream imgStream, Stream outStream, ProcessImageSettings settings)
File "ImageResizePlugin.vb", line 102, col 9, in MemoryStream ImageResizePlugin.ResizeImageMIP(MemoryStream ms)

@saucecontrol
Copy link
Owner

saucecontrol commented Oct 14, 2023

Ok, that'll be an incompatible version of the libpng codec plugin. You need to update that to https://www.nuget.org/packages/PhotoSauce.NativeCodecs.Libpng/1.6.39-preview1. The dependencies are set up correctly in the packages (e.g. the older codec library is version restricted to < 0.14) https://www.nuget.org/packages/PhotoSauce.NativeCodecs.Libpng/1.6.37-preview1#dependencies-body-tab.

Same applies to all of the codec plugin packages. There are updated versions of all of them tied to the new version of the MagicScaler package.

I'm curious how you got in that state since the SDK should refuse to restore an incompatible combination of dependent packages.

@hheexx
Copy link
Author

hheexx commented Oct 14, 2023

Aha....Tnx.

Here are my project references:

<PackageReference Include="PhotoSauce.MagicScaler" Version="0.14.0" />
<PackageReference Include="PhotoSauce.NativeCodecs.Giflib" Version="5.2.1-preview1" />
<PackageReference Include="PhotoSauce.NativeCodecs.Libheif" Version="1.13.0-preview1" />
<PackageReference Include="PhotoSauce.NativeCodecs.Libjpeg" Version="2.1.4-preview1" />
<PackageReference Include="PhotoSauce.NativeCodecs.Libjxl" Version="0.7.0-preview1" />
<PackageReference Include="PhotoSauce.NativeCodecs.Libpng" Version="1.6.37-preview1" />
<PackageReference Include="PhotoSauce.NativeCodecs.Libwebp" Version="1.2.4-preview1" />

I updated main MagicScaler package from visual studio but I did not see plugin updates as they are still published as previews and I did not check "include prerelase" in VS package manager.

I'm not sure what SDK does in that situation but I received no warning and everything compiled nicely....

@saucecontrol
Copy link
Owner

Ah, that's a bummer. I knew they wouldn't show up by default in the VS UI because of the preview version, but I assumed the package restore would fail and give you a clue.

I really prefer to leave the codec packs tagged as preview for now, but that's obviously not a great user experience. Thanks for letting me know about the friction there. For now, I'll add something to the release notes to call out the incompatibility.

@saucecontrol
Copy link
Owner

saucecontrol commented Oct 14, 2023

FYI, I tried to reproduce this to log a bug against the NuGet client, but I'm getting a warning as expected in both the 7.0 and 8.0RC2 SDKs (also visible in the VS Error List window).

warning NU1608: Detected package version outside of dependency constraint: PhotoSauce.NativeCodecs.Libpng 1.6.37-preview1 requires PhotoSauce.MagicScaler (>= 0.13.2 && < 0.14.0) but version PhotoSauce.MagicScaler 0.14.0 was resolved.

Maybe you missed the warning? I guess they wouldn't make it an error severity because they have no way of knowing whether the incompatibility will actually cause issues at runtime or not...

@hheexx
Copy link
Author

hheexx commented Oct 14, 2023

yea I missed the warning, i have a lot :)
tnx!

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