Log4Net in Infopath form code... - InfoPath Dev
in

InfoPath Dev

Log4Net in Infopath form code...

Last post 11-15-2009 06:58 AM by Karsten Brocksieper. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-14-2009 06:42 AM

    Log4Net in Infopath form code...

    Hello,

    I would like to use the free logging component "Log4Net" (http://logging.apache.org/log4net/index.html) in my own web enabled forms. As I know that I can´t use private member variables in my code I would like to initialize the Log4Net object with a formstate variable.

    But unfortunately if I used the following code:

    private Log4Net log4Net{
      get {return (Log4Net)FormState["log4Net"];}
      set {FormState["log4Net"] = value;}
    }

    ... and in the "FormEvents_Loading"

    FormState.Add("log4Net",new Log4Net());

    I get a "System.Runtime.Serialization.SerializationException"

    Can anyone help me with the correct initializing of the log4Net variable...

    Thank you very much.

    Karsten
    Filed under:
  • 11-15-2009 03:46 AM In reply to

    Re: Log4Net in Infopath form code...

    Why are you adding it to the FormState? That's what is causing the error. Can you declare a variable in your code and add it to that instead? Something public should work. Not sure why private won't work (please explain where you read that).

    Patrick Halstead
    Project Manager at Qdabra
  • 11-15-2009 06:58 AM In reply to

    Re: Log4Net in Infopath form code...

    Hi Patrick,

    ... to tell the truth --- I don´t understand what you mean. In my experience it is not allowed to declare a member variable in the form code regardless of 'private' or 'public'. If you declare such a variable for example:

    private (or public) Log4Net log4net;

    you can´t upload the form in the 'Central administration' in SharePoint cause SharePoint shows an error message while you want upload such a form...

    In the meantime I have found the reason why you can´t store the 'Log4Net' object in FormState. It´s because the 'Log4Net' object is not serializable and as FormState implements IDictionary --- it is essential that every variable which you want to store in FormState must be serializable...

    Regards,

    Karsten
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.