Aspose with ILMerge

We use Aspose.PDF with ILMerge to create an all-in-one exe for PDF processing.

We previously were using Aspose.PDF with .NET 2.0. Everything worked well with ILMerge, and we were able to use our merged EXE just fine.

We upgraded to Aspose.PDF with .NET 4.0. Everything works well before we use ILMerge. When we try to run our “merged” program, however, we get a “value cannot be null” exception from within the assembly when we get to this line of code:

new Aspose.Pdf.License().SetLicense(“Aspose.Pdf.lic”);

We have the license set to be an embedded resource in both situations so I am unsure what the problem is here. Has anybody else had trouble getting ILMerge to set the license correctly?

Hi Scott,

Thanks for using our products.

Since the release of Aspose.Pdf for .NET 6.0.0, there has been a slight change in the mechanism of using license file as an embedded resource. Please use Default Namespace of the project as prefix to license file name and set the value of License.Embedded property to true. Please visit the following link for further details on Using as Embedded resource

In case you still face the same problem or you have any further query, please feel free to contact. We are sorry for your inconvenience.

Thank you for the response. However, the recommended code changes do not seem to have an effect.

If we prefix the license name with our default namespace, as is shown in the link you provided, we get the “Cannot find license file” exception. This occurs in both the merged and unmerged result.

Our code looks like:

namespace PDFConverter // Default Namespace

Aspose.Pdf.License license = new Aspose.Pdf.License();
license.Embedded = true;

If I use the existing license (“Aspose.Pdf.lic”) and keep the License.Embedded = true; part, the unmerged version works again, but we still get the “value cannot be null” exception after using ILMerge.

Please advise.

Hi Scott,

Thanks for your patience and sorry for the delayed response.

Can you please share the sample application along with the license file so that we can test the scenario at our end. Please attach the application with in this forum thread and visit the following link for details on How to send a license?

Please do not include the license file along with the project when uploading over the forums. We are sorry for your inconvenience.

Was this issue ever resolved?

I am facing the same problem. I’m using Aspose.Pdf for .NET 7.3.0 with .NET 4.0. I’m using it to convert an existing pdf file to a doc file. This works wonderfully by itself. However, when I package the aspose.pdf.dll together with my executable using ILMerge, I receive a ArgumentException (Value cannot be null.). The stack trace is a bit garbled, but I will provide it below anyway.

At first I thought that it was a problem with the string that I was passing into the constructor (Aspose.Pdf.Document(string)), so I simplified everything down in an effort to pinpoint the problem. Right now, I’m only newing up an Aspose.Pdf.Document object passing in zero parameters. I’m still receiving the same exception from this operation.

I believe that the license has nothing to do with this issue and that it is just an issue with packaging the assembly with ILMerge.

Again, was this issue resolved? Or is there a resolution to my issue?

Thank you,

Stack Trace:

System.ArgumentException: Value cannot be null.:diamonds:
at §.?.?:slight_smile:(? , Object[] )
at §.?.?:slight_smile:(? )
at ↓.♫…ctor(:clubs::slight_smile: , ? , Boolean )
at §.?.?:slight_smile:(:clubs::slight_smile: , ? , Boolean )
at ▬.:heart:…ctor(Stream , :slight_smile: , Boolean )
at §.?.?:slight_smile:(Stream , Boolean , Boolean )
at §.?.?:slight_smile:(Stream , Boolean )
at §.:slight_smile::slight_smile:…ctor(Stream , Int32 )
at §.?.?:slight_smile:(Stream , Int32 )
at §.:slight_smile::slight_smile:…ctor(Int32 )
at §.?.?:slight_smile:(Int32 )
at ▬.►…ctor(Int32 , String , String , String )
at Aspose.Pdf.Document…ctor()
at PdfToDoc.PdfToDoc.ConvertPdf()
at PdfToDoc.PdfToDoc.Main(String[] args)

Hi Matthew,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the details.

I am able to reproduce your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-34221 for further investigations. We will update you via this forum thread regarding any update.

Sorry for the inconvenience,

Hi Matthew,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have received a feedback regarding your issue. This is actually a known issue. We obfuscated Aspose.Pdf for .NET by SmartAssembly. We checked this issue with SmartAssembly and got the following reply :

You can't use ILMerge with a SmartAssembly protected assembly because the renaming and other features break the Reflection ILMerge uses to work out its' own renaming scheme.

We are sorry for the inconvenience,