from the event log of my windows server 2012, the aspose.cell was hitting the issue
i am using the Aspose.Cells 24.10.0 and i can actually see the dependencies at the bin folder any idea?
image.png (14.8 KB)
Application: w3wp.exe
CoreCLR Version: 8.0.1024.46610
.NET Version: 8.0.10
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for ‘SkiaSharp.SKObject’ threw an exception.
—> System.DllNotFoundException: Unable to load DLL ‘libSkiaSharp’ or one of its dependencies: The specified module could not be found. (0x8007007E)
at SkiaSharp.SkiaApi.sk_version_get_milestone()
at SkiaSharp.SkiaSharpVersion.get_Native()
at SkiaSharp.SkiaSharpVersion.CheckNativeLibraryCompatible(Boolean throwIfIncompatible)
at SkiaSharp.SKObject…cctor()
— End of inner exception stack trace —
at SkiaSharp.SKObject.DeregisterHandle(IntPtr handle, SKObject instance)
at SkiaSharp.SKObject.set_Handle(IntPtr value)
at SkiaSharp.SKNativeObject.Finalize()
@tonyutada
Cause
The error you’re encountering, specifically the System.TypeInitializationException
for SkiaSharp.SKObject
, indicates that the application is unable to load the native library libSkiaSharp
or one of its dependencies. This is often due to missing or incompatible native libraries required by SkiaSharp, which is used by Aspose.Cells for rendering.
Solution
To resolve this issue, you can follow these steps:
-
Check Dependencies: Ensure that all required native libraries for SkiaSharp are present in your application’s bin folder. You should have libSkiaSharp.dll
and any other dependencies that it may require.
-
Platform Compatibility: Verify that the architecture of your application (x86 or x64) matches the architecture of the SkiaSharp native libraries. If your application is running in a 64-bit environment, ensure you have the 64-bit version of the libraries.
-
Install SkiaSharp via NuGet: If you haven’t already, consider installing SkiaSharp via NuGet, which will automatically manage the dependencies for you. You can do this by running the following command in your Package Manager Console:
Install-Package SkiaSharp
-
Update Aspose.Cells: Ensure that you are using the latest version of Aspose.Cells, as updates may include fixes for compatibility issues.
-
Check for Missing Dependencies: Use a tool like Dependency Walker or the .NET Assembly Binding Log Viewer (Fuslogvw.exe) to identify any missing dependencies that might be causing the issue.
Code
If you need to check for the presence of the library programmatically, you can use the following code snippet:
try
{
// Attempt to load the SkiaSharp library
var skiaSharpLib = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
Console.WriteLine($"Loaded SkiaSharp version: {skiaSharpLib}");
}
catch (DllNotFoundException ex)
{
Console.WriteLine($"Error loading SkiaSharp: {ex.Message}");
}
Next Steps
After following the above steps, restart your application and monitor the event log for any further errors. If the issue persists, reach out to Aspose support with detailed information about your environment and the steps you’ve taken.
Please let me know if you need further assistance!
it was only hitting on the deployed server, your suggestion wasn’t having much help
@tonyutada
We recommend you to kindly try using our latest version: Aspose.Cells for .NET v25.7.
If you still find the issue, kindly do share your complete sample (runnable) code and template Excel file (if any) to reproduce the issue on our end, we will check it soon.
by far if i remove worksheet.AutoFitColumns(); it will work for some records to write to excel.
because this issue is only hitting on paricular server, other server seems OK,(windows server 2012). my local console sample is having the runtime (used by .deps.json)
@tonyutada
The worksheet.AutoFitColumns() method measures and changes the column width. The internal logic of this method is complex, and it is difficult to accurately locate the issue based on exception. Would you like to provide your sample files and runnable test code? We will check it soon.
@tonyutada,
Moreover, since the failure only occurs on one specific Windows Server 2012 machine (where you are using worksheet.AutoFitColumns()), while others are fine. This generally suggests a problem with missing native DLLs, incompatible runtime setups, or a misconfigured deployment. libSkiaSharp.dll is either missing or can’t be loaded due to a missing dependency (like a missing Windows DLL or incompatible architecture) on that server, etc. Please ensure libSkiaSharp.dll is deployed fine or not. You may check the bin or publish output directory/folder. You should see:
libSkiaSharp.dll
SkiaSharp.dll
If you’re using .NET 8, the native Skia DLL may be inside a runtimes/folder (e.g., runtimes/win-x64/native/libSkiaSharp.dll).
In case you still find the issue, as requested, please provide your sample files and runnable (test) code or a standalone app with resource files.