Web Dev Matters and Me

Web Development Matters - HTML, XML, C#, .NET, AJAX/Javascript(jQuery), CSS, XML-XSLT

ME - LIFE,Philippines, Tokyo, ECE, PhilNITS/JITSE,情報処理, 日本語

things about Philippines, gaming, C# development and web development, how to make money in stock trading

Web Dev Matters and Me

Configuration files - which is for what

When we are developing applications, one of the considerations that we do is to make some configurable sections that will allow anyone to change how the application run without modifying the codes. app config for window based applications and web.config for web applications. how about for a SQLCLR? they are located in sqlservr.exe.config. This can be located easily by looking at the installation folder of SQL and find the Binn folder. Look for the latest version of SQL (you might see 8.0, 9.0, 10.0).

Now, how these config files take effect is quite tricky. For a web.config hosted in IIS, you must reset the IIS first, thru the IIS GUI or by running iisreset in command prompt. As for the machine.config, you must restart the machine, which means you should be careful deciding to shutdown a machine, especially if it is used as a server. For sqlserver configs, there is no need to restart the machine, as changes take effect after restarting the SQL Server service (Start> Run > services.msc     then scroll to the sqlserver service).

A .NET Framework error occurred during execution of user-defined routine or aggregate

Msg 6522, Level 16, State 1, Procedure, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate :
System.TypeInitializationException: The type initializer  threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ServiceModel.WSReliableMessagingFebruary2005Version' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.
System.IO.FileLoadException:
   at System.ServiceModel.WSReliableMessagingFebruary2005Version..ctor()
   at System.ServiceModel.WSReliableMessagingFebruary2005Version..cctor()
System.TypeInitializationException:
   at System.ServiceModel.WSReliableMessagingFebruary2005Version.get_Instance()
   at System.ServiceModel.Channels.ReliableSessionBindingElement..ctor(Boolean ordered)
   at System.ServiceModel.WSHttpBindingBase.Initialize()
   at System.ServiceModel.WSHttpBinding..ctor()
   at ADMS.CommonClrSQL.StoredProcedures..cctor()
System.TypeInitializationException:
.
The statement has been terminated.

====================================================


Hi! If you are experiencing the above error, I'm guessing that you are trying to invoke a Webservice from SQL.  Just lately, I was involved with a task that performs some upgrade in SQL Server database and making the database make a call to a WCF Service. Now, the problem is, whenever the procedure/trigger will make a request to the hosted service, it will throw an Error. This made us sleepless for days, trying to figure out the fix, but fortunately we are able to make things working.

We are experiencing the above error because the assemblies deployed in GAC(Global Assemby Cache) is different to assemblies loaded to the database. So, we tried to load the assembly from the GAC itself. There is a caution here. Be sure that the correct version of dll is loaded. Since there are 32 bit and 64 bit assemblies, you must refer FIRST to the GAC MSIL then if the assembly doesnt exist in there, refer to the appropriate X-Bit folder(32 or 64).

Doing this solved our problem. On our case, the error message we get now points to a machine configuration. An endpoint entry which is a malformed XML must be removed or commented out, then have the machine restart (since it is machine configuration).

FB Connect