Updating to latest version of GleamTech.DocumentUltimate results in 'Could not load file or assembly 'SkiaSharp'
Problem reported by Dean Parker - 6/21/2023 at 7:24 AM
We are currently running version 6.7.1  of GleamTech.DocumentUltimate in a .Net Core 7.0 project.
If we try and update the package to the latest version 6.9.5 our project then no longer runs with this error:

'Could not load file or assembly 'SkiaSharp, Version=, Culture=neutral, PublicKeyToken=0738eb9f132ed756'. The system cannot find the file specified.'

Is this a package dependency that should be coming with 
GleamTech.DocumentUltimate ?

I see here https://docs.gleamtech.com/documentultimate/html/version-history.htm#v6.8.0 that SkiaSharp is mentioned. If I add the package to my project alongside DocumentUltimate then I get another error:

Could not load file or assembly 'SixLabors.Fonts, Version=, Culture=neutral, PublicKeyToken=d998eea7b14cab13'. The system cannot find the file specified.'

This one is harder to reolsve because I cannot find a SixLabors.Fonts package. There is a SixLabors.ImageSharp but even with this installed I still get the issue about SixLabors.Fonts being missing.

Right now it seems version 6.7.1 is the last working version of Document Ultimate that I can use. Is there some issue with Nuget not sorting out these dependencies with DocumentUltimate is updated?

4 Replies

Reply to Thread
Cem Alacayir Replied
Employee Post Marked As Resolution
Strange, there is no hard dependency to SkiaSharp or SixLabors DLLs but for interoperability (casting from/to objects from those libraries) these libs are linked but they should be needed only when you use them with GleamTech. I suspect, some code in your project scans the DLLs for reflection purpose.

GleamTechConfiguration.EnsureAssemblies method which ensures GleamTech's assemblies are loaded and initialized.You may need to call this method in entry point/startup of your application, if you receive "Could not load file or assembly ..." errors. 
You can observe this behaviour if your application calls some methods which scans assemblies for reflection purpose (reflection-only type access does not trigger DLL's module initializer),for example ASP.NET Core's endpoints.MapControllers method and SimpleInjector's RegisterMvcControllers method. So to prevent errors on those methods, you can call this method before such methods. 

Cem Alacayir Replied
Employee Post
FYI, I couldn't replicate the problem when running the below method in a project which references GleamTech DLLs:

public void TestAppDomainGleamTechTypes()
    Console.WriteLine("Populating types in GleamTech assemblies loaded in AppDomain:");

    var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
    for (var i = 0; i < loadedAssemblies.Length; i++)
        var a = loadedAssemblies[i];

        if (a.FullName != null && !a.FullName.StartsWith("GleamTech", StringComparison.OrdinalIgnoreCase))

        Console.WriteLine($"{i}. {a.FullName}");
        Console.WriteLine("\tPopulated {0} types without CLR errors.", a.GetTypes().Length);

The above code populates types via reflection. If there was a dependency problem, it would throw an error.

In your project, I suspect something is populating referenced assemblies in the GleamTech.Common assembly where it shouldn't. Referenced assemblies should not be probed if the code does not need it.
Dean Parker Replied
Thanks for your information. I tried adding latest GleamTech.DocumentUltimate on another project of similar type (.Net 7) and it worked fine. So this seems to be something specific about my project as you say.
For the moment I have added the below to get it running. I will check our project some more. 

    <PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta19" />
    <PackageReference Include="SkiaSharp" Version="2.88.3" />
Cem Alacayir Replied
Employee Post
Do you set TextWatermark.Font  property in your project? GleamTech.Drawing.Font class has implicit cast operators so maybe that's the problem (we may need to change them to explicit operators if so)

Reply to Thread