Welcome on Kweetix Technical Blog

Tuesday, August 30, 2011

WCF Services with large data : Increasing maxStringContentLength value has no effect

The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SendStatistic'. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

This message occurs even if you have increased the value of MaxStringContentLength.

Solution : Create a "default" binding section in the basicHttpBinding section of the server config file.

<binding>
<readerQuotas maxDepth="32" maxStringContentLength="102400" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>


For customBinding, this problem can be solved by adding an attribute maxReceivedMessageSize="524288" to httpTransport directive : 

<httpTransport maxReceivedMessageSize="524288"/>


Thursday, August 25, 2011

Visual Studio Setup : Copy files to Application Data or Local Data

To put stuff in a sub-directory of the Common Application Data folder or Local Application Data from a VS Setup project, here's what you do:

Right-click your setup project in the Solution Explorer and pick "View -> File System".

Right-click "File system on target machine" and pick "Add Special Folder -> Custom Folder".

Rename the custom folder to "Common Application Data Folder." (This isn't the name that will be used for the resulting folder, it's just to help you keep it straight.)

Change the folder's DefaultLocation property to "[CommonAppDataFolder][Manufacturer]\[ProductName]" or "[LocalAppDataFolder][Manufacturer]\[ProductName]". Note the similarity with the DefaultLocation property of the Application Folder, including the odd use of a single backslash.

Marvel for a moment at the ridiculous (yet undeniable) fact that there is a folder property named "Property." Babies full of rabies, who comes up with this shit?

Change the folder's Property property to "COMMONAPPDATAFOLDER" or "LOCALAPPDATAFOLDER".

Data files placed in the "Common Application Data" folder will be copied to "\ProgramData\Manufacturer\ProductName" (on Vista) or "\Documents and Settings\All Users\Application Data\Manufacturer\ProductName" (on XP) when the installer is run.

Data files placed in the "Local Application Data" folder will be copied to "\Users\[username]\AppData\Local\Manufacturer\ProductName" (on Vista) or "\Documents and Settings\[username]\Application Data\Manufacturer\ProductName" (on XP) when the installer is run.