-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
XPS documents in .NET Core can't be opened #3546
Comments
Please clarify the problem you're experiencing so that we can route the issue appropriately. Are you receiving a runtime exception? (If so, please provide the exception message and repro code.) Are you receiving no exception at runtime but still seeing incorrect behavior? |
This issue has been automatically closed due to no response from the original author. Please feel free to reopen it if you have more information that can help us investigate the issue further. |
When opening an XPS file which is created from a V4 XPS printer driver we can't access the 'FixedDocumentSequenceReader' because it's null. Code below works perfect in full framework but doesn't in .net Core 3.1 using(var strm = File.OpenRead("path to xps file"))
{
var package = Package.Open(strm, FileMode.Open, FileAccess.Read);
var inMemoryPackageName = string.Format("memorystream://{0}.xps", Guid.NewGuid());
PackageStore.AddPackage(new Uri(inMemoryPackageName), package);
var xpsDoc = new System.Windows.Xps.Packaging.XpsDocument(package, CompressionOption.Fast, inMemoryPackageName);
var fixedDocSeqReader = xpsDoc.FixedDocumentSequenceReader;
var printTicket = fixedDocSeqReader.PrintTicket; //<- nullreferenceexception here because fixeddocumentsequencereader is null
} |
@olowk I think you should open a new issue about that, instead of commenting on a closed one. |
Thanks for the repro code! I'll get someone to transfer this to the WPF repo so that the appropriate area owners will get notification of the issue. |
Thank you for the report, @olowk. Which versions of .NET Core and Windows are you using? |
I am using .net core 3.1 and Windows 10 updated to latest version. |
@GrabYourPitchforks @terrajobst did you ever test this? .NET SDK 5.0.202 |
@wstaelens Could you provide a XPS file that you cannot open on .Net Core. I tried to reproduce your issue but it worked on my machine. Thank you. |
Files were a bit too big, zip file 200mb can be found here on onedrive: https://1drv.ms/u/s!ArFv7v_tfAlngrQFZNhqp6HU-vkDMQ?e=WWhie5 You will find:
When you go to .NET Framework is able to open an .XPS with all these separate files. This is the problem that we are facing (besides XPS being terribly slow). |
Hey @wstaelens, I've done some digging and the problem is the splitted files in .piece file. In .Net Framework, the code for System.IO.Packaging.* was in WindowsBase. The version in WindowsBase supports .piece file while the version in System.IO.Packaging assembly does not. I'm not sure who the owner of System.IO.Packaging is but according to this, its not owned by the WPF team. Tagging @adamsitnik, @carlossanlop and @jozkee because it looks like they are the area owners (See "Notes" in the area owners file). Thanks |
Thanks @ThomasGoulet73 I'm surprised nobody else has seen this 😮 😞 I don't understand why XPS driver/template (Visual Studio) produces an XPS file which is not compatible with .NET Core/.NET 5. (or there might be, an undocumented setting that we are not aware of.) Really strange that we are the first to report this. I hope that XPS printing could be improved and that the performance issues as mentioned will also be tackled. From the link you provided, I'll tag some other users also from the system.xml/system.io: @ericstj @jeffhandley @davidfowl @HongGit @StephenMolloy @buyaa-n @joperezr @krwq /* rant / |
Hey @wstaelens, I understand your frustration but also I looked in .Net repos and I haven't seen any issue about the usage of .piece file which leads me to believe that it is not used a lot because it's not supported at all in .Net Core. Also, from what I've seen, it's not a simple on/off switch that can enable .piece support, there is a non-trivial amount of code required to make it work. Maybe some configuration is required in your XPS driver to disable .piece files. You might want to look into that. My advice would be to open an issue in dotnet/runtime to request support for .piece so that member of the .Net team responsible of this area can respond. Thanks |
@ThomasGoulet73 we'll have a look if we can see something in our driver but searching for .piece in the Microsoft documentation doesn't give any results. I hope it has something to do with Interleaving Mode, we'll test this. On the other hand I somebody at the Microsoft team (which one?) should adjust .NET 5 (.NET Core) so that XPS files with .piece files can be opened, because this is being produced here by default and it works in .NET Framework 4.8 by default. (and as always hoping that there will be some XPS performance and memory improvements... 🤞) |
Please see dotnet/runtime#51929 (comment) from @KevinCathcart |
😢 🤞 🐼 bump |
For updates see: dotnet/runtime#51929 (comment) Prototype code: dotnet/runtime@main...KevinCathcart:interleave |
any updates? |
@lindexi can you maybe add this code from Kevin to a PR so that it can be fixed? code: dotnet/runtime@main...KevinCathcart:interleave (PR: dotnet/runtime#78374 ) (info: dotnet/runtime#51929 (comment) ) |
@wstaelens Sorry, I'm afraid I don't have enough free time to finish such a big job |
@wstaelens I believe this issue can be closed since this issue is unrelated to WPF and the PR that adds interleaving support (dotnet/runtime#97898) was merged in |
Besides the impersonation limitation I reported earlier we have also found that XPS documents coming from a virtual printer can't be opened in .NET Core.
We first have to extract the XPS files, combine all part files to a single file and then create the XPS file again. Then we can open an XPS file in .NET Core.
Is this by design or a bug?
Because we don't have to do this in .NET Full Framework.
The text was updated successfully, but these errors were encountered: