We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Use Aspose.PDF for .NET in Windows Service to Process PDF documents - Set License Error

I have a Windows Service using Aspose.PDF. I get a weird / bad event error on ctor()
When setting the license.
Any idea what is wrong?

public ServiceOCR()
{
try
{
InitializeComponent();

            Aspose.Pdf.License license = new Aspose.Pdf.License();
            // Set license
            license.SetLicense("Aspose.Total.lic");
            Console.WriteLine("License set successfully.");

EventLog

Application: iPDF.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NotSupportedException
** at System.Reflection.Emit.InternalAssemblyBuilder.GetManifestResourceNames()**
** at #=qHhd0cTRP5jgVQDGlQId2f71ctAtxmuAWs6avmswhMn0=.#=zubMDdt0DL4uReF9yYlOlyWxHnjY3(Assembly #=zhkypHCeaMYGNANKYSoaylohQuulqDIUaSA==)**
** at #=qHhd0cTRP5jgVQDGlQId2f71ctAtxmuAWs6avmswhMn0=.#=zKmMZRbg=(Assembly #=zhkypHCeaMYGNANKYSoaylohQuulqDIUaSA==)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zksK3NJBV3FGTXAFJo2bc1AY=(Object #=zFK5NcAs=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zhk__CeezJfv_s0cSaoOR__R$tMjMGIHHAk4918c=(MethodBase #=zFK5NcAs=, Boolean #=zUylXmEg=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zLcZHbIEE9c0AMReF8NO3i$I=(#=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI= #=zFK5NcAs=, #=qjPK8N0BenBUYGxJcFiD7iUH5RxRVCZVWLmmk_pashw8= #=zUylXmEg=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zjhQGuMxNafdmq$cFxaSn6vI=()**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean #=zFK5NcAs=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zksK3NJBV3FGTXAFJo2bc1AY=(Object #=zFK5NcAs=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zUyLJmE_7DfhJjKCnvVIssZSfYvRY0wMc_4PXpg4=()**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zn6yCxs0yw$BnRiWXemh0YlRQx0g7(Object #=zFK5NcAs=, UInt32 #=zUylXmEg=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean #=zFK5NcAs=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zIVEng7mB8ObjtL8ThqXDi8Zzf4G5p1a2Kw==()**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zZtNjmnCg2WhMWXHFiTThSONmegT3XZbDRb2KTAx_J7mA(Object[] #=zFK5NcAs=, Type[] #=zUylXmEg=, Type[] #=zVeJcQh4=, Object[] #=zMtxa2D0=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=z_76SQozXsKRjj_ZM4LyyzO9FLcO8eAhwy7jLN$4=(Stream #=zFK5NcAs=, Int32 #=zUylXmEg=, Object[] #=zVeJcQh4=, Type[] #=zMtxa2D0=, Type[] #=z635xTn4=, Object[] #=zMCvzfPg=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=z0IEFwOq5XBI5kltG1N22x19VcNfZCGuAQw==(Int32 #=zFK5NcAs=, Type[] #=zUylXmEg=, Type[] #=zVeJcQh4=, Boolean #=zMtxa2D0=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=znxtNfkrljC0XX$Anecq4Ofn9vCTG(#=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI= #=zFK5NcAs=, #=qjPK8N0BenBUYGxJcFiD7iUH5RxRVCZVWLmmk_pashw8= #=zUylXmEg=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zjhQGuMxNafdmq$cFxaSn6vI=()**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean #=zFK5NcAs=)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zksK3NJBV3FGTXAFJo2bc1AY=(System.Object)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zUyLJmE_7DfhJjKCnvVIssZSfYvRY0wMc_4PXpg4=()**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zn6yCxs0yw$BnRiWXemh0YlRQx0g7(System.Object, UInt32)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean)**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zIVEng7mB8ObjtL8ThqXDi8Zzf4G5p1a2Kw==()**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zZtNjmnCg2WhMWXHFiTThSONmegT3XZbDRb2KTAx_J7mA(System.Object[], System.Type[], System.Type[], System.Object[])**
** at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=z2l4IzUHTLyMvG08wrdafkmPe26eJyWdNfw==(System.IO.Stream, System.String, System.Object[], System.Type[], System.Type[], System.Object[])**
** at Aspose.Pdf.License.SetLicense(System.String)**
** at iPDF.ServicePDF…ctor()**
** at iPDF.Program.Main()**

@jon_elster_i3intel_com

Would you please make sure to give full path to the license file in your web service project. Also, in case of WCF service, depending upon its hosting:

  • if it is custom ServiceHost - then you can set license in service host start event
  • if it is IIS - then set license can be called in Global.asax

In case issue still persists, please let us know.

Path is in Root and embedded resource in .Net project. It’s a windows service!

@jon_elster_i3intel_com

The issue does not seem related to the API. Would you please check if method GetManifestResourceNames() is called anywhere inside your project. If yes, then please call it inside a static method. Let us know if it does not resolve your issue.

I don’t call that method. Just call the following.
Any ideas? what does that error mean?
thx

        Aspose.Pdf.License license = new Aspose.Pdf.License();
        // Set license
        license.SetLicense("Aspose.Total.lic");
        Console.WriteLine("License set successfully.");

@jon_elster_i3intel_com

Apparently the exception shows the reason is GetManifestResourceNames() method. However, please share a sample Windows Service Project in .zip format with us so that we can test it in our environment and address the issue accordingly.

Hi
It’s a Windows Service. Get this on Starting the service… calling SetLicense.
I will forward the solution, I could not replicate on my server.
thanks

Same error my laptop

Run as windows service - install from bin/debug

Application: iPDF.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NotSupportedException
at System.Reflection.Emit.InternalAssemblyBuilder.GetManifestResourceNames()
at #=qHhd0cTRP5jgVQDGlQId2f71ctAtxmuAWs6avmswhMn0=.#=zubMDdt0DL4uReF9yYlOlyWxHnjY3(Assembly #=zhkypHCeaMYGNANKYSoaylohQuulqDIUaSA==)
at #=qHhd0cTRP5jgVQDGlQId2f71ctAtxmuAWs6avmswhMn0=.#=zKmMZRbg=(Assembly #=zhkypHCeaMYGNANKYSoaylohQuulqDIUaSA==)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zksK3NJBV3FGTXAFJo2bc1AY=(Object #=zFK5NcAs=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zhk__CeezJfv_s0cSaoOR__R$tMjMGIHHAk4918c=(MethodBase #=zFK5NcAs=, Boolean #=zUylXmEg=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zLcZHbIEE9c0AMReF8NO3i$I=(#=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI= #=zFK5NcAs=, #=qjPK8N0BenBUYGxJcFiD7iUH5RxRVCZVWLmmk_pashw8= #=zUylXmEg=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zjhQGuMxNafdmq$cFxaSn6vI=()
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean #=zFK5NcAs=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zksK3NJBV3FGTXAFJo2bc1AY=(Object #=zFK5NcAs=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zUyLJmE_7DfhJjKCnvVIssZSfYvRY0wMc_4PXpg4=()
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zn6yCxs0yw$BnRiWXemh0YlRQx0g7(Object #=zFK5NcAs=, UInt32 #=zUylXmEg=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean #=zFK5NcAs=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zIVEng7mB8ObjtL8ThqXDi8Zzf4G5p1a2Kw==()
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zZtNjmnCg2WhMWXHFiTThSONmegT3XZbDRb2KTAx_J7mA(Object[] #=zFK5NcAs=, Type[] #=zUylXmEg=, Type[] #=zVeJcQh4=, Object[] #=zMtxa2D0=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=z_76SQozXsKRjj_ZM4LyyzO9FLcO8eAhwy7jLN$4=(Stream #=zFK5NcAs=, Int32 #=zUylXmEg=, Object[] #=zVeJcQh4=, Type[] #=zMtxa2D0=, Type[] #=z635xTn4=, Object[] #=zMCvzfPg=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=z0IEFwOq5XBI5kltG1N22x19VcNfZCGuAQw==(Int32 #=zFK5NcAs=, Type[] #=zUylXmEg=, Type[] #=zVeJcQh4=, Boolean #=zMtxa2D0=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=znxtNfkrljC0XX$Anecq4Ofn9vCTG(#=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI= #=zFK5NcAs=, #=qjPK8N0BenBUYGxJcFiD7iUH5RxRVCZVWLmmk_pashw8= #=zUylXmEg=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zjhQGuMxNafdmq$cFxaSn6vI=()
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean #=zFK5NcAs=)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zksK3NJBV3FGTXAFJo2bc1AY=(System.Object)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zUyLJmE_7DfhJjKCnvVIssZSfYvRY0wMc_4PXpg4=()
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zn6yCxs0yw$BnRiWXemh0YlRQx0g7(System.Object, UInt32)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zO7_$JavMgKCOaB1y7Qep_CxPlkn0FKQbSw==(Boolean)
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zIVEng7mB8ObjtL8ThqXDi8Zzf4G5p1a2Kw==()
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=zZtNjmnCg2WhMWXHFiTThSONmegT3XZbDRb2KTAx_J7mA(System.Object[], System.Type[], System.Type[], System.Object[])
at #=qpJ42zOc7kjrzod6bmej0GTh486XGVhsQdpcj2x$tgQI=.#=z2l4IzUHTLyMvG08wrdafkmPe26eJyWdNfw==(System.IO.Stream, System.String, System.Object[], System.Type[], System.Type[], System.Object[])
at Aspose.Pdf.License.SetLicense(System.String)
at iPDF.ServicePDF…ctor()
at iPDF.Program.Main()

@jon_elster_i3intel_com

We were able to notice the issue in our environment and found that the issue was related to loading resources at runtime. Please try to put the license file in the output directory of the solution and change the property of the license file in solution as following:

Licensefileprop.png (5.2 KB)

We tried this and it resolved the issue at our end. We also removed the link from your previous reply because it contained license information. Please always share such sensitive information in a private message. We recommend removing the license from the project which is uploaded to the Dropbox.

thank you again!