Reading Application-Config in CF 2.0

Hi there,

is there any chance to read the data stored in a .config-file with CF 2.0 The namespace "System.Configuration" is completely missing in the Objectbrowser!

Any chance to get the code without self-coding

thanks in advance and best regards

Reiner

PS.: In the good old days of Win32-Programming my nightmare was the "ERROR_ACCESS_DENIED"-error! Nowadays this is the "NotSupportedException", which I get (at least) 10 times a day!!!!



Answer this question

Reading Application-Config in CF 2.0

  • L. Lysaght

    Configuration file is just an XML - open it as XML in DOM or XmlTextReader and read what you need. It's not without coding, but fairly easy. OpenNetcf.org has some classes in OpenNETCF.Configuration namespace to simplify this task.

    As to NotSupportedException, I’m surprised you’re running into it that often. With perhaps exception of System.IO.Directory.GetCurrentDirectory it’s not that easy to hit, mostly happens with advanced P/Invoke attempts.



  • JonesEJ20

    Hi there, I an also getting this problem. I have written quite a large application and some minor bugs have come up during the testing phase, now suddenly I cannot debug due to this happening. This project was to be delivered to a client yesterday. Any urgent help would be most welcome.



    Thanks


  • kasra007

    Ilya,

    I have already done so (reading the .config with DOM). Some words to the "NotSupportedException": The application that I develop this time consists of a couple of Windows-Forms. In the system-generated code of nearly each of these forms I had some "NotSupportedExceptions"! Don't know where they came from (Debugger doesnt stop). Though my app is running correctly. But I wonder...

    Thank you and kind regards

    Reiner


  • methylamine

    Paul,

    can you send a bit of code, (the lines, where the exception occurs)

    regards

    Reiner


  • Samlazyeye

    Ilya,

    the problem is: in a vitual machine running XP SP2 I'm NOT getting the "NotSupportedExceptions" (means the VS-Debugger does'nt stop)! On my "real" develop-machine (W2K3 R3 Server x64-Edition) I'm GET the exception(s)! One of the exceptions occurs in the following code-block, which initializes a PictureBox with my logo:

    this.picLogo.Dock = System.Windows.Forms.DockStyle.Bottom;
    ---> this.picLogo.Image = ((System.Drawing.Image)(resources.GetObject("picLogo.Image")));
    this.picLogo.Location = new System.Drawing.Point(0, 114);
    this.picLogo.Name = "picLogo";
    this.picLogo.Size = new System.Drawing.Size(240, 95);
    this.picLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;

    The second line of code throws the exception and I really doesn't know why!

    You have any Idea

    best regards

    Reiner



  • Huxwell

    Oh, you're not actually getting the exception, it's in designer generated code That's probably done to indicate particular platform can't do something. As long as you're not getting that at runtime it's not a problem at all.



  • Reading Application-Config in CF 2.0