SKDocument.CreateXps() returns null in a .NET Core App
See original GitHub issueHi,
Creating an Xps Document fails when run in a dotnet core app (the returned document instance is null), while the same code works with the full .NET Framework.
using (var stream = new SKFileWStream("test.xps"))
using (var document = SKDocument.CreateXps(stream))
{
// document = null if run from a dotnet core 2.0 app!
}
I am using the newest SkiaSharp nuget: 1.60.0
(FYI: SKDocument.CreatePdf()
works fine from a dotnet core app.)
As the Xps Backend is provided by Skia I would expect it to work in SkiaSharp as well.
Take care, Martin
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
SKCanvas Class (SkiaSharp)
CreateXps (stream); // get the canvas from the page var canvas = document. ... The null canvas is a canvas that ignores all...
Read more >Why C# PowerShell.Create() returns null in case of .NET ...
Create() returns the proper PowerShell object; When I call same code from the .NET Core project then it returns null .
Read more >How to Troubleshoot Asp.net Core ...
CloudConfigurationManager.GetSetting() returning null values can be caused by several reasons, including incorrect settings, unavailable ...
Read more >ASP.NET Core FromBody: Not working? Or returning null ...
The ASP. NET Core FromBody. Is it not working? Or returning null ? This video will provide a solution to this common .NET...
Read more >How do you handle EF Core null return values in your ...
The Id is sent from the client application and if they have access to an Id that doesn't exist in the database, then...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I managed to find the issue. It was the fact that the COM was not initialized.
With the full .NET Framework, COM is already initialized as it is used by the framework itself. I am not sure how I can integrate this into SkiaSharp as this must be done outside the scope of
SKDocument
. the native skia has a nice utility type that I think I may be able to duplicate…Here is a workaround:
The fix in v1.60.1 will be:
NOTE: this is only needed for some .NET Core apps. The full .NET Framework already initializes COM.