Free Support Forum - aspose.com

Error in saving a document to an XPS Stream

We’re using the latest version of Aspose.Words under MS Server 2008 R2 (in a virtual machine) and get the following error:

Cannot find resource ‘Aspose.Resources.HatchMasks.dat’.

I cannot find any information about this. We have been using this call before without problems. Can you suggest a reason why this might be happening, and how to fix it?

Thanks in advance,
Frank Alviani

Hi Frank,

Thanks for your request. “Aspose.Resources.HatchMasks.dat” is an internal Aspose.Words resource that is used to draw hatch fills. It is stored inside Aspose.Words.dll as an embedded resource. So there should not be any problem with accessing this resource.

By the way, does the problem occur only with XPS format or with PDF too? Because Aspose.Words uses this resource upon exporting to PDF too.

Best regards,

Is there any way we can identify what feature of the source document may be causing the problem? Is this a known problem? If so, is there a work-around or is a fix already scheduled to be released?

Thanks in advance,
Frank Alviani

Hi Frank,

Thanks for your request. No, this is not known issue. You are the first customer who experienced such problem.

So could you please answer the questions I asked in my previous post to help us to analyze the problem.

The only reason o the problem I can imagine at the moment is that you tried to disassemble Aspose.Words.dll and remove this resource from it.

Best regards,

HI,

Sorry for the delay in replying. We have tried saving the same document in PDF format and get exactly the same error, so I believe it to be an actual bug. Again, we have not altered your delivered software in any way.

Looking forward to your usual quick reply,
Frank Alviani

Hi Frank,

Thank you for additional information. I still cannot reproduce the problem on my side. Have you tried using the latest version of Aspose.Words (9.8.0)? You can download it from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

In addition, could you please create a simple application that will allow us to reproduce the problem? We will check again and provide you more information.

Best regards,

I’ve downloaded the 9.8.0 version as recommended and will post a followup with the results of our testing :slight_smile:

Thanks,
Frank Alviani

Thank you, Frank. We will wait for your inputs.

I have attached a document that reliably causes the resource not found error. Replacing the table cell hatching with a solid gray fill allows the document to print correctly. Hopefully this will help.

Frank Alviani

Hi

Thank you for additional information. But unfortunately, I still cannot reproduce the problem on my side. I can successfully convert your document to XPS.

Maybe, you can create a simple application that will allow me to reproduce the problem.

Best regards,

We are working in a web application; a C# project targeted at .Net 4.0. We update merge fields in the document and then print it from the web server using the sample code Aspose has provided. It is not actually necessary to save it as an XPS document to cause the error. Hopefully this helps.

I’m afraid I don’t have any spare time available at this point to develop a desktop application using a copy of our web-application code to see if it still happens from a desktop application.

Frank Alviani

Hi Frank,

Thank you for additional information. One more question. Does the error occur every time when you attempt to convert the file to XPS? I suppose maybe the problem occurs because you are converting few documents simultaneously to XPS in multiple thread and this causes the problem. But I am very doubt that this might be a reason.

Best regards,

Actually, the error happens when just printing from the web server, although that does require converting to XPS in your code. Documents are processed one at a time in sequence; there is no threading taking place. Removing the hatching pattern from the document results in the error no longer happening.

Frank

Hi Frank,

Thank you for additional information. Yes, from the error message I see that problem occurs only if the document contains hatching pattern. The resource that Aspose.Words cannot access contains hatches patterns used upon rendering the document.

But unfortunately, I still have no idea how I can reproduce the problem on my side and why this might occur on your side.

You can try to extract this resource from Aspose.Words.dll, just to make sure it exists and accessible. Here is simple code:

[Test]

public void Test001()

{

// Get Aspose.Words assembly.

Assembly asm = Assembly.GetAssembly(typeof (Aspose.Words.Document));

Console.WriteLine(asm.FullName);

// Get Names of embedded resources.

string[] resourceNames = asm.GetManifestResourceNames();

foreach (string resourceName in resourceNames)

Console.WriteLine(resourceName);

// Extract Aspose.Resources.HatchMasks.dat resource.

using (Stream resourceStream = asm.GetManifestResourceStream("Aspose.Resources.HatchMasks.dat"))

{

// Write it to file.

SaveStreamToFile(@"Test001\HatchMasks.dat", resourceStream);

}

}

public void SaveStreamToFile(string fileFullPath, Stream stream)

{

if (stream.Length == 0) return;

// Create a FileStream object to write a stream to a file

using (FileStream fileStream = System.IO.File.Create(fileFullPath, (int)stream.Length))

{

// Fill the bytes[] array with the stream data

byte[] bytesInStream = new byte[stream.Length];

stream.Read(bytesInStream, 0, (int)bytesInStream.Length);

// Use FileStream object to write to the specified file

fileStream.Write(bytesInStream, 0, bytesInStream.Length);

}

}

Have you tried to recreate your project? Maybe this could help to resolve the problem.

Best regards,

Thanks for the sample. The list of resources from the assembly (as saved to a StringBuilder) is:

assembly name=Aspose.Words, Version=9.4.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
Aspose.Words.Resources.ShapeTypes.txt
Aspose.Words.Resources.AllStyles.doc
Aspose.Words.Resources.Aspose.License.BlackList.Real.xml
Aspose.Words.Resources.Blank.doc
Aspose.Foundation.Resources.NoImage.png
Aspose.Foundation.Resources.HatchMasks.dat

But attempting to retrieve the resource returns a null. Notice that the name of the resource in the assembly is different from the name of the resource we’re attempting to retrieve, and that the dll is complaining about.

Frank

Hi Frank,

Thanks for this additional information.

I have tried Alexey's code using Aspose.Words Version 9.4 and the full name of the HatchMasks resource matches "Aspose.Resources.HatchMasks.dat". I'm not sure as to why you would get a different name on your side.

Are you able to attach your version of Aspose.Words.dll here? We look further into this for you.

Thanks,

I will need to upload it via FTP - our firewall catches outgoing executables of any flavor, even compressed. Please send the FTP login info to me at my membership email: frank@familypianoco.com

Thanks in advance,
Frank

Hi Frank,

By the way, have you tried using the latest version of Aspose.Words? Also, even if you cannot use the latest version, I would advise you to re-download 9.4.0 version of Aspose.Words and use it. It is quite strange that names of resources are incorrect on your side.

Best regards,