Search code examples
c#app-configdynamicpdf

Exception in c# exe at runtime using cete.dynamicpdf and an entry appsettings in config file


I have inherited a c# exe application from a ex-collegue. We use this exe as batch called by another application (and by command-line for test and debug). In its app.config I see only the configuration for Log4Net (present also in reference).

The application uses ceTE.DynamicPDF.40.

I wanted to insert a key-value setting in app.config, for some configuration. Whatever element I use the application throws an exception at runtime. Before never did.

The line in which it breaks is:

Document document = new Document();

The exception informations are (translated):

ex.Source --> ceTe.DynamicPDF.40
ex.Message --> The type initializer for 'ceTe.DynamicPDF.Document' threw an exception.
ex.StackTrace -->in ceTe.DynamicPDF.Document..ctor() in BatchStampaRegistroDeleghe.BusinessLogic.BusinessManager.GestioneCover (String & Path, List`1 args, Int32 Startpage, String Sectional) in C: \ ... \ BusinessManager.cs: line 779
ex.InnerException.Source --> System.Configuration
ex.InnerException.Message --> Unable to initialize the configuration system
ex.InnerException.StackTrace --> in System.Configuration.ConfigurationManager.PrepareConfigSystem () in System.Configuration.ConfigurationManager.get_AppSettings () in ceTe.DynamicPDF.Document..cctor ()

If I delete the entry from app.config the exe come back to work.

Had someone similar problems before? Thanx in advance for any advice.


Solution

  • ceTe.DynamicPDF.40.dll reads the app.config file to see if there are any license keys present. If a license key is found, it will apply the license key to remove the watermark on the PDF.

    Based on the information you posted, it appears that the ceTe.DynamicPDF.40.dll is unable to read the app.config file due to the changes made to it. The error “Unable to initialize the configuration system” typically indicates an issue with an invalid or out of place entry in app.config. Please double check the syntax of the new settings you are adding to the app.config and make sure they are added at the correct location.

    Disclaimer: I work for ceTe Software, the company that develops DynamicPDF libraries.