Software Architecture-Exception-Snapin project-Porting from .Net 3.5 to .Net 4.0

March 13, 2011

Exception:

Could not load file or assembly ‘XXXXX, Version=5.5.3484.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Environment:
There is a snapin project in solution. After porting solution from visual studio 2008/.Net 3.5 to visual studio 2010, the above exception is appearing.

Solution:
Add an environmental variable named COMPLUS_Version with value v4.0.30319 where v4.0.30319 is your version of .Net framework
This change will solve the above problem.


Software Architecture – Exception -Windows Vista + SQL Server Express edition- Failed to compile the Managed Object Format (MOF) file

August 10, 2010

Environment:
Windows Vista + SQL Server Express edition
Exception:

SQL Server Setup Failed to compile the Managed Object Format (MOF) file ***.mof. To proceed, see “Troubleshooting an Installation of SQL Server 2005” or “How to: View SQL Server 2005 Setup Log Files” in SQL Server 2005 Setup Help documentation.

Actual error will look like as:

Solution:
The problem comes from corruption in the WMI repository, and it can be repaired easily. From a command prompt, running as administrator, run:
winmgmt /salvagerepository
You’ll get an error, but the command has sent a stop request to the WMI service. Run the command a second time, and it will repair the repository and the SQL Server installation can continue.

Reference:
http://msdn.microsoft.com/en-us/library/aa394525(VS.85).aspx


Software Architecture – Exception -MaxArrayLength property on the XmlDictionaryReaderQuotas object

August 5, 2010

Environment:
Visual Studio 2010/C# 4.0, WCF, NHibernate, Silverlight 4
Exception:
While uploading a file by converting file content into array of bytes and sending it to server side via WCF, generates following exception.

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:***. The InnerException message was ‘There was an error deserializing the object of type ****. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 57216.’.

Solution:
If you search XmlDictionaryReaderQuotas in object browser, you will find as:



So there is a configuration option in Servicemodel configuration, for setting the maximum array size limit. You can change the default limit of maxArrayLength tag by adding following XML in Service configuration of WCF Service as:

<bindings>
        <basicHttpBinding>
          <binding
                   maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="0:50:0" openTimeout="0:50:0" receiveTimeout="0:50:0" sendTimeout="0:50:0"                  
                   >
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2097152"  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </binding>

          </basicHttpBinding>
</bindings>

Reference:
http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpbinding.readerquotas.aspx