Note that there are some explanatory texts on larger screens.

plurals
  1. PODataContractSerializer - Configuration system failed to initialize -- app config setting
    primarykey
    data
    text
    <p>I'm using the DataContractSerializer as a standalone piece to serialize some objects that use DataContract/Member... Unfortunately, it keeps throwing an exception if i keep a custom App.Config section added to my solution's config settings that has absolutely nothing to do with this process... For instance, my config is set like so:</p> <pre><code>&lt;configuration&gt; &lt;appSettings&gt; &lt;!--stuff goes here --&gt; &lt;/appSettings&gt; &lt;MyCustomSectionItDoesntLike&gt; &lt;!--stuff goes here --&gt; &lt;/MyCustomSectionItDoesntLike&gt; &lt;/configuration&gt; </code></pre> <p>I then take the object and try to write using a memorystream...</p> <pre><code>DataContractSerializer serializer = new DataContractSerializer(item.GetType()); using (MemoryStream memoryStream = new MemoryStream()) { serializer.WriteObject(memoryStream, item); } </code></pre> <p>If i remove the MyCustomSectionItDoesntLike from the config settings, it works just fine, but when i put it back in, an exception gets triggered:</p> <p>Message:</p> <blockquote> <p>The type initializer for 'System.Runtime.Serialization.DiagnosticUtility' threw an exception.</p> </blockquote> <p>Inner:</p> <blockquote> <p>Unrecognized configuration section MyCustomSectionItDoesntLike. (D:\test\bin\x86\Debug\test.vshost.exe.config line 47)</p> </blockquote> <p>Im unsure as to why it doesnt care what that setting is anywhere in the project except when im going to serialize... Is there a setting, or a config section i need to add for this to work properly?</p> <p>thanks!</p> <h2>Update</h2> <p>total bonehead error.... had nothing to do with the serializer...</p> <pre><code>&lt;configuration&gt; &lt;configSections&gt; &lt;!--This is where i blew it --&gt; &lt;section name="MyCustomSectionItDoesntLike" type="System.Stuff.Stuff" /&gt; &lt;/configSections&gt; &lt;appSettings&gt; &lt;!--stuff goes here --&gt; &lt;/appSettings&gt; &lt;MyCustomSectionItDoesntLike&gt; &lt;!--stuff goes here --&gt; &lt;/MyCustomSectionItDoesntLike&gt; &lt;/configuration&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload