Closed bojankostic81 closed 2 years ago
Make sure you're explicitly using something from that DLL, otherwise it'll be trimmed. https://devblogs.microsoft.com/dotnet/app-trimming-in-net-5
I am calling the method MozJpeg.Recompress(inBytes.AsSpan(), quality, subsampling, flags)
from MozJpegSharp, which is referenced as NuGet package in my project.
I have tried to add assembly-trimming, like:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EmitSourceMap>true</EmitSourceMap>
<EmitTypes>true</EmitTypes>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>CopyUsed</TrimMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetJS" Version="0.3.12" />
<PackageReference Include="MozJpegSharp" Version="2.1.12" />
</ItemGroup>
</Project>
but then I get the following error:
Uncaught (in promise) Error: System.TypeLoadException: Could not resolve type with token 0100001e from typeref (expected class 'System.Runtime.Serialization.ISerializable' in assembly 'System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e')
Any ideas what might be a problem and how to resolve it?
Something in that third party lib is probably trying to access System.Runtime.Serialization.ISerializable
via reflection, while trimmer can't track that kind of dependencies. Try preserving the type via linker: https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/configure-linker
This issue is stale because it has been open 14 days with no activity. It will be automatically closed in 7 days.
Hi, thanks for this great project! I am trying to implement MozJpegSharp image compression based on the HelloWorld example from the ReadMe you provided, and I'm getting an error. Here are the relevant files:
ImageCommpression.csproj
JS function
I ran
dotnet publish
to create the dotnet.js file and I am able to import the module, but I receive an error in console:When I run same program as a console application everything is working fine. Do you have any ideas what might be a problem?