<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Mohamed Sharaf's Blog</title><subtitle type="html">Hi, This blog will be my window to discuss my interests in .NET Framework, ASP.NET, SQL Server and Sharepoint. I hope I can add a value for who will pass by :).

This blog is showing my own prospective. It doesn't represent any official announcements/ commitments of my employer.</subtitle><id>http://blogs.msdn.com/mosharaf/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/mosharaf/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2005-11-17T18:57:00Z</updated><entry><title>How to handle expired SQL logins’ passwords in client code</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2009/01/22/how-to-handle-expired-sql-logins-passwords-in-client-code.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2009/01/22/how-to-handle-expired-sql-logins-passwords-in-client-code.aspx</id><published>2009-01-22T18:04:00Z</published><updated>2009-01-22T18:04:00Z</updated><content type="html">&lt;P&gt;Microsoft is always advise customers to use the new security features for SQL Logins in SQL Server. As you know SQL Logins are the logins where the login name and password are saved inside SQL Server and SQL Server is responsible for authenticated this login. We don't depend on Windows to validate them. Of course Windows authentication is more recommended as it's more secure but many times the customer has to use SQL login. &lt;/P&gt;
&lt;P&gt;Starting SQL Server 2005, SQL Logins can have a policy inherited from the domain policy or the local machine policy so we can control the complexity of the password and how often this password will be expired. For more information about the password policy, refer to &lt;A href="http://msdn.microsoft.com/en-us/library/ms161959(SQL.90).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms161959(SQL.90).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms161959(SQL.90).aspx&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;But usually when I recommend customers to use password expiration, they are concerned about their live application and how the application would respond the situation when the password is expired. I wrote a sample application by C# to handle this. For unmanaged code, you can follow up the instructions in this &lt;A href="http://msdn.microsoft.com/en-us/library/ms131024.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms131024.aspx"&gt;article&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;To use managed code to respond to the password expiration, first we need to detect when the password expires. This would be by checking the SQLException error number, it's number &lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;18487. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;To change the password, I'm using &lt;A href="http://msdn.microsoft.com/en-us/library/ms162169(SQL.90).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms162169(SQL.90).aspx"&gt;SQL Server Management Objects (SMO)&lt;/A&gt; I'm assuming the structure of the connecting module would be like this &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Try to connect normally to SQL Server, using &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;SqlConnectionStringBuilder &lt;/SPAN&gt;class to build the connection string. I'm assuming that the client saves the password in a protected storage so we need a function like &lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;getPassword()&lt;/SPAN&gt;to get the password from this storage &lt;/LI&gt;
&lt;LI&gt;If the password is expired (error 18487), the application is responsible to generate a new password &lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;generateNewPassword()&lt;/SPAN&gt;and use the &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;ServerConnection &lt;/SPAN&gt;class to change the password. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;I wrote pseudo implementation for &lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;getPassword() &lt;/SPAN&gt;and&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt; generateNewPassword()&lt;/SPAN&gt;but in real code, you should add your own algorithm. &lt;/P&gt;
&lt;P&gt;Here's the code. It's implemented as a console application &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Collections.Generic; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Linq; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Text; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Data.SqlClient; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; Microsoft.SqlServer.Management.Smo; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; Microsoft.SqlServer.Management.Common; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; TestSQLConnection &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Program &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SqlConnectionStringBuilder&lt;/SPAN&gt; builder=&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;SqlConnectionStringBuilder&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.DataSource=&lt;SPAN style="COLOR: #a31515"&gt;"myserver\\sql2k5"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.InitialCatalog=&lt;SPAN style="COLOR: #a31515"&gt;"AdventureWorks"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.UserID=&lt;SPAN style="COLOR: #a31515"&gt;"test"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.Password=getPassword(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SqlConnection&lt;/SPAN&gt; conn = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;SqlConnection&lt;/SPAN&gt;(builder.ConnectionString); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;try &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Trying to connect to SQL Server..."&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;conn.Open(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Connection succeeded Connected to server version {0}, \n wiating your command..."&lt;/SPAN&gt;,conn.ServerVersion); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ReadLine(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;catch&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;SqlException&lt;/SPAN&gt; ex) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ForegroundColor = &lt;SPAN style="COLOR: #2b91af"&gt;ConsoleColor&lt;/SPAN&gt;.Green; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ex.Number == 18487) &lt;SPAN style="COLOR: green"&gt;//the password expired &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"the login password has expired, do you want to generate a new passwoed and use it(type 'Y' or 'N')"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; answer=&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ReadLine(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (answer == &lt;SPAN style="COLOR: #a31515"&gt;"Y"&lt;/SPAN&gt; || answer==&lt;SPAN style="COLOR: #a31515"&gt;"y"&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; newPassword = generateNewPassword(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ServerConnection&lt;/SPAN&gt; srvConn = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;ServerConnection&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;srvConn.ServerInstance = &lt;SPAN style="COLOR: #a31515"&gt;"myserver\\sql2k5"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;srvConn.LoginSecure = &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;srvConn.Login = &lt;SPAN style="COLOR: #a31515"&gt;"test"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;srvConn.Password = getPassword(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;srvConn.ChangePassword(newPassword); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Password has changed"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;savePassword();&lt;SPAN style="COLOR: green"&gt;//save the new password for next connection &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;System.Threading.&lt;SPAN style="COLOR: #2b91af"&gt;Thread&lt;/SPAN&gt;.Sleep(3000);&lt;SPAN style="COLOR: green"&gt;//give SQL server a chance to change the password and be ready &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Trying to connect to SQL Server again..."&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.DataSource = &lt;SPAN style="COLOR: #a31515"&gt;"myserver\\sql2k5"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.InitialCatalog = &lt;SPAN style="COLOR: #a31515"&gt;"AdventureWorks"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.UserID = &lt;SPAN style="COLOR: #a31515"&gt;"test"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;builder.Password = getPassword(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;conn = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;SqlConnection&lt;/SPAN&gt;(builder.ConnectionString); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;conn.Open(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Connection succeeded Connected to server version {0}, \n wiating your command..."&lt;/SPAN&gt;, conn.ServerVersion); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ReadLine(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt; &lt;SPAN style="COLOR: green"&gt;//close &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;Process&lt;/SPAN&gt;.GetCurrentProcess().CloseMainWindow(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;else &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ForegroundColor = &lt;SPAN style="COLOR: #2b91af"&gt;ConsoleColor&lt;/SPAN&gt;.Red; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"error while opening connection"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Error No: "&lt;/SPAN&gt; + ex.Number); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Message : "&lt;/SPAN&gt; + ex.Message); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ForegroundColor = &lt;SPAN style="COLOR: #2b91af"&gt;ConsoleColor&lt;/SPAN&gt;.White; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ReadLine(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;finally &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (conn != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; &amp;amp;&amp;amp; conn.State == System.Data.&lt;SPAN style="COLOR: #2b91af"&gt;ConnectionState&lt;/SPAN&gt;.Open) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;conn.Close(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;internal&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; getPassword() &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: green"&gt;//you should implement the logic to get the password from encrypted storage &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #a31515"&gt;"test"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;internal&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; savePassword() &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: green"&gt;//you should implement the logic to save the password in encrypted storage &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;internal&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; generateNewPassword() &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: green"&gt;//you should implement the logic to randomly generate new complex password &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #a31515"&gt;"test"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9368168" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /><category term="SQL Server" scheme="http://blogs.msdn.com/mosharaf/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Moving the tempdb to unknown location</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2008/07/11/moving-the-tempdb-to-unknown-location.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2008/07/11/moving-the-tempdb-to-unknown-location.aspx</id><published>2008-07-11T01:29:00Z</published><updated>2008-07-11T01:29:00Z</updated><content type="html">&lt;P&gt;One of my friends called me for a problem at a customer site. The problem simple is that the customer wanted to move the tempdb in SQL Server 2005 to a new location but because of a typo the new path of the file is pointing to a folder not a file. Something like this &lt;STRONG&gt;&lt;EM&gt;"C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\" &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The alter statement would be something like this &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;alter&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;database&lt;/SPAN&gt; tempdb &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;modify&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;file&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;tempdev&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;fileName&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\'&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The result of this statement would be &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: Courier New"&gt;The file "tempdev" has been modified in the system catalog. The new path will be used the next time the database is started. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;So next time SQL Server tries to access the tempdb it will fail and the problem comes worse if you restarted the SQL Server, the Server won't start and this message will be logged in the Application Event log &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Segoe UI"&gt;FCB::Open: Operating system error 3(error not found) occurred while creating or opening file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\'. Diagnose and correct the operating system error, and retry the operation. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;So what would be the solution of something like this? &lt;/P&gt;
&lt;P&gt;I've tried this scenario and worked, I thought it would be better if I published it so if someone faced this situation (although, it's very rare situation) it would help. &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;First we need to start SQL Server with minimum configuration in console mode; go the SQL Server binary folder (commonly in &lt;EM&gt;C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn&lt;/EM&gt;) &lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Open a console window and run this command &lt;/DIV&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;sqlservr.exe –c –f –m &lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;So this starts SQL Server in console mode (not a service) and with minimum configuration and also with single user mode. You should see some messages like you see when you open the error log file &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV&gt;Open another console window and run this command &lt;/DIV&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;Sqlcmd /A &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This will connect to the default instance on the machine using windows authentication though Dedicated Administrator Connection (DAC) &lt;/P&gt;
&lt;P&gt;After logging you can alter the tempdb to add the path of the correct file; like this. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;alter database tempdb modify file (name=tempdev, fileName='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;tempdb.mdf') &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Now return back to the first console window where you started the SQL Server and press Ctrl+C this will shutdown the server &lt;/P&gt;
&lt;P&gt;Start SQL Server normally and the problem is now solved &lt;SPAN style="FONT-FAMILY: Wingdings"&gt;J&lt;/SPAN&gt; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8718941" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term="SQL Server" scheme="http://blogs.msdn.com/mosharaf/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>MS File Encryption</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2007/06/20/ms-file-encryption.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2007/06/20/ms-file-encryption.aspx</id><published>2007-06-20T16:55:00Z</published><updated>2007-06-20T16:55:00Z</updated><content type="html">&lt;P&gt;As I promised in my last post, here's the MS File Encryption program (MS stands for Mohamed Sharaf not Microsoft of course ;))&amp;nbsp;based on the &lt;A href="http://blogs.msdn.com/mohamed_sharafs_blog/archive/2007/05/29/back-to-mssecurity-library-again.aspx" mce_href="http://blogs.msdn.com/mohamed_sharafs_blog/archive/2007/05/29/back-to-mssecurity-library-again.aspx"&gt;MSSecurity Library&lt;/A&gt;. The application is pretty simple; you can encrypt a single file or entire folder. &lt;/P&gt;
&lt;P&gt;The application adds the extension MSEnc to the file when encrypting and remove it when decrypting just to identify which files are encrypted and which not in case you are using it to periodically encrypt your secret folder so it won't re-encrypt encrypted files again. The application is bundled with help document and you can get it directly &lt;A href="http://msharaf.members.winisp.net/files/MSFileEncryption.pdf" mce_href="http://msharaf.members.winisp.net/files/MSFileEncryption.pdf"&gt;here&lt;/A&gt;. &lt;/P&gt;&lt;A href="http://msharaf.members.winisp.net/files/MSFileEncryption.exe"&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/mainWindow.JPG" mce_src="http://msharaf.members.winisp.net/Images/mainWindow.JPG"&gt; &lt;/A&gt;
&lt;P&gt;Download the File Encryption program &lt;A href="http://msharaf.members.winisp.net/files/MSFileEncryption.exe" mce_href="http://msharaf.members.winisp.net/files/MSFileEncryption.exe"&gt;HERE&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Please have a nice encryption &lt;SPAN style="FONT-FAMILY: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3424785" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /><category term="General" scheme="http://blogs.msdn.com/mosharaf/archive/tags/General/default.aspx" /></entry><entry><title>Back to MSSecurity library again</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2007/05/29/back-to-mssecurity-library-again.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2007/05/29/back-to-mssecurity-library-again.aspx</id><published>2007-05-29T15:02:00Z</published><updated>2007-05-29T15:02:00Z</updated><content type="html">&lt;P&gt;If you have seen my &lt;A href="http://blogs.msdn.com/mohamed_sharafs_blog/archive/2005/11/09/MSecurityLibrary.aspx" mce_href="http://blogs.msdn.com/mohamed_sharafs_blog/archive/2005/11/09/MSecurityLibrary.aspx"&gt;previous post&lt;/A&gt; about the class library that I developed to encrypt text or files using symmetric encryption (&lt;EM&gt;Rijndael algorithm&lt;/EM&gt;). So you would already know that it was developed using .NET Framework 1.1. I've upgraded the library to .NET Framework 2.0 and fixed a bug I discovered in the decryption methods. &lt;/P&gt;
&lt;P&gt;I already described the methods in this library before so allow me to copy-and-paste them from my previous post &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"&gt;The library called &lt;STRONG&gt;&lt;EM&gt;MSecurityLibrary&lt;/EM&gt;&lt;/STRONG&gt; and it consists of only two classes &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; COLOR: black; FONT-SIZE: 9pt"&gt;&lt;STRONG&gt;Encryption: &lt;/STRONG&gt;does the symmetric encryption using &lt;EM&gt;Rijndael &lt;/EM&gt;algorithm and a key size of 256 bits. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;&lt;SPAN style="COLOR: black; FONT-SIZE: 9pt"&gt;&lt;STRONG&gt;Hashing: &lt;/STRONG&gt;hash any string with &lt;EM&gt;MD5&lt;/EM&gt; hashing algorithms&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"&gt;Encryption class has 11 public methods. I'll describe the main functions here. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; encryptFile(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; sourceFile,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; distinationFile,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; password) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; encryptFile(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; sourceFile,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; distinationFile,&lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] key) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;These two methods encrypt a file using either a password or an array of bytes as a key. You can use&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Courier New"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;the&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Courier New"&gt; generateKey() &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;method to generate that key and save it in a file (usually should be put in a floppy disk to make it more secure). &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; decryptFile(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; sourceFile,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; distinationFile,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; password) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; decryptFile(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; sourceFile,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; distinationFile,&lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] key) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"&gt;These two methods are the opposite of the others. They decrypt a file using either a password or a key. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; encryptString(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; inputString,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; password) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; encryptString(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; inputString,&lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] key) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"&gt;These two do the same but for strings. They take inputString parameter which will be encrypted using a password or a key &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; decryptString(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; inputString,&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; password) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; decryptString(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; inputString,&lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] key) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"&gt;The opposite to the previous two methods, &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"&gt;Hashing class has only one public method &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; HashStringWithMD5(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; password) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"&gt;This method takes a string and hashes it using MD5 algorithms and returns a string. This method is very powerful if you want to hash passwords in a database in case you want to save them secured. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The new version of the library can be found &lt;A href="http://msharaf.members.winisp.net/files/MSecurityLibrary2_bin.zip" mce_href="http://msharaf.members.winisp.net/files/MSecurityLibrary2_bin.zip"&gt;here&lt;/A&gt;. If you want to take a look at the source code, you will find it &lt;A href="http://msharaf.members.winisp.net/files/MSSEncryption2.zip" mce_href="http://msharaf.members.winisp.net/files/MSSEncryption2.zip"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;I developed a windows application to encrypt and decrypt files or entire folders based on this library and I'm planning to post it with the full source code in my next post (God Willing). &lt;/P&gt;
&lt;P&gt;See you in the next post sooooon &lt;SPAN style="FONT-FAMILY: Wingdings"&gt;J&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;//Mohamed Sharaf &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2967442" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /></entry><entry><title>Visual Studio Team System Survey</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2007/04/09/visual-studio-team-system-survey.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2007/04/09/visual-studio-team-system-survey.aspx</id><published>2007-04-09T16:24:00Z</published><updated>2007-04-09T16:24:00Z</updated><content type="html">&lt;P&gt;&lt;IMG style="WIDTH: 281px; HEIGHT: 49px" title=vsts alt=vsts src="http://msharaf.members.winisp.net/Images/vsts.gif" width=281 height=49 mce_src="http://msharaf.members.winisp.net/Images/vsts.gif"&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;Visual Studio product team has recently launched this survey. Take this opportunity to say what you like and you don't in the product.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;You can request any new features or add the comments you like.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;The link to the survey is &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #666e91; FONT-SIZE: 9pt"&gt;&lt;A target=_blank href="http://c2.microsoft.fr/0d26d4f2ccc64f449b07a379372d72b5/?elng=1033" mce_href="http://c2.microsoft.fr/0d26d4f2ccc64f449b07a379372d72b5/?elng=1033"&gt;http://c2.microsoft.fr/0d26d4f2ccc64f449b07a379372d72b5/?elng=1033&lt;/A&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #666e91; FONT-SIZE: 9pt"&gt;&amp;lt;/Mohamed&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2060857" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term="General" scheme="http://blogs.msdn.com/mosharaf/archive/tags/General/default.aspx" /></entry><entry><title>Cross post with Master pages</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2007/03/15/cross-post-with-master-pages.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2007/03/15/cross-post-with-master-pages.aspx</id><published>2007-03-15T14:50:00Z</published><updated>2007-03-15T14:50:00Z</updated><content type="html">&lt;P&gt;I got a feedback for the &lt;A href="http://blogs.msdn.com/mohamed_sharafs_blog/archive/2005/08/10/InsideMasterPages.aspx" mce_href="http://blogs.msdn.com/mohamed_sharafs_blog/archive/2005/08/10/InsideMasterPages.aspx"&gt;Master Pages post&lt;/A&gt; asking about mixing master pages with cross post. Here's the scenario. &lt;/P&gt;
&lt;P&gt;We have a content page that has one textbox and one button, the page code would be like this &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;@&lt;/SPAN&gt; &lt;SPAN style="COLOR: #a31515"&gt;Page&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;Language&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="VB"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;MasterPageFile&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="~/MasterPage.master"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;AutoEventWireup&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="false"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;CodeFile&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="master_form.aspx.vb"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;Inherits&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="master_form"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Untitled Page"&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;%&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Content&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Content1"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;ContentPlaceHolderID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ContentPlaceHolder1"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;Runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Server"&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBox&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="id"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server"&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBox&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Button&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Button1"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red; BACKGROUND-COLOR: yellow"&gt;PostBackUrl&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue; BACKGROUND-COLOR: yellow"&gt;="~/result.aspx"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Button"&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;/&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;As you can see, the button posts to another page called result.aspx. &lt;/P&gt;
&lt;P&gt;When you get the data posted using &lt;STRONG&gt;Request.Form("id")&lt;/STRONG&gt;, this would result in empty string because there's no entry with this name in the form collection in the form collection. Because the content page is merged with the master page so the id of the textbox would be ctl00$ContentPlaceHolder1$id (ctl00 is the form element, and contentPlaceHoder1 is the id of the contentPlaceHolder) so if you would like to get it from the form collection, you would write it in the form of &lt;STRONG&gt;Request.Form("ctl00$ContentPlaceHolder1$id"). &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This technique is not appropriate as you can see, so the most appropriate technique is to use the PreviousPage property. &lt;A href="http://msdn2.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx"&gt;PreviousPage&lt;/A&gt; is a property for the Page class that has a reference to the previous page if you are doing Server.Transfer or Cross Posting. &lt;/P&gt;
&lt;P&gt;You can use PreviousPage and FindControl method to get any control you have on the previous page like this code snippet. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; ctlTextBox &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; TextBox = &lt;SPAN style="COLOR: blue"&gt;Nothing &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Not&lt;/SPAN&gt; Page.PreviousPage &lt;SPAN style="COLOR: blue"&gt;Is&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;ctlTextBox = &lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(PreviousPage.Form.FindControl(&lt;SPAN style="COLOR: #a31515"&gt;"ContentPlaceHolder1"&lt;/SPAN&gt;).FindControl(&lt;SPAN style="COLOR: #a31515"&gt;"id"&lt;/SPAN&gt;), TextBox) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps &lt;SPAN style="FONT-FAMILY: Wingdings"&gt;J&lt;/SPAN&gt; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1886707" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /><category term="ASP.NET" scheme="http://blogs.msdn.com/mosharaf/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>How to move objects from Schema to another in SQL 2005</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2007/02/21/how-to-move-objects-from-schema-to-another-in-sql-2005.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2007/02/21/how-to-move-objects-from-schema-to-another-in-sql-2005.aspx</id><published>2007-02-21T16:53:00Z</published><updated>2007-02-21T16:53:00Z</updated><content type="html">&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;If you are building CLR stored procedure and you want this stored procedure to be part of a schema called xyz. When you write the name of the procedure in the SqlProcedure attribute "xyz.myproc" and deploy this procedure, the visual studio deployed it with dbo schema and the name of the procedure will be dbo.xyz.myproc. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;In this case and in many other cases, you may need to move the procedure to the xyz schema. Fortunately you can do this pretty simple with only 1 SQL statement. You can use Alter Schema TSQL command for this. The syntax as following &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;ALTER SCHEMA schema_name TRANSFER object_name &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;schema_name is the name of the schema that you want the object to be transferred to (xyz in our case) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;object_name is the full name of the object including its schema (dbo.xyz.myproc in our case) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;Note: &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;Unfortunately, this TSQL statement can't deal with multi parts name (names with more than one dot) so per in mind to use names with no dot in the middle (i.e. dbo.xyz_myproc) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;I think this workaround is pretty easy. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1735216" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /><category term="SQL Server" scheme="http://blogs.msdn.com/mosharaf/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Changing application settings programmatically in .NET Framework 2.0</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2007/01/19/changing-application-settings-programmatically-in-net-framework-2-0.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2007/01/19/changing-application-settings-programmatically-in-net-framework-2-0.aspx</id><published>2007-01-19T03:14:00Z</published><updated>2007-01-19T03:14:00Z</updated><content type="html">&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;As I promised to provide a component to enable you to change the values of the application-scope settings in .NET Framework 2.0, I'm now providing it. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;It's a very simple dll written by C#, you can find the Source code &lt;A href="http://msharaf.members.winisp.net/files/ApplicationSettingsWriter-Source.zip" mce_href="http://msharaf.members.winisp.net/files/ApplicationSettingsWriter-Source.zip"&gt;here&lt;/A&gt;. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;To use this dll you will need to get instance from the SettingWriter class as following &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;ApplicationSettingsWriter.&lt;SPAN style="COLOR: teal"&gt;SettingsWriter&lt;/SPAN&gt; writer = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ApplicationSettingsWriter.&lt;SPAN style="COLOR: teal"&gt;SettingsWriter&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;Then use the indexes of this object to change the value of the settings like this &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;writer[&lt;SPAN style="COLOR: maroon"&gt;"sampleSettings"&lt;/SPAN&gt;] = &lt;SPAN style="COLOR: maroon"&gt;"Omar"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;In this example, "sampleSettings" is the key of the setting in the app.config. In Visual Studio 2005, you can access your settings visual by opening the properties window of the project (see figure below). &lt;/SPAN&gt;&lt;/P&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/appSettings.GIF"&gt; &lt;/A&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;Writing the previous line indeed changes the value of the app.config but if you tried this line to retrieve the value, you wouldn't get your change &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: teal"&gt;MessageBox&lt;/SPAN&gt;.Show(Properties.&lt;SPAN style="COLOR: teal"&gt;Settings&lt;/SPAN&gt;.Default.sampleSettings); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;That's because .NET Framework loads the application settings with the loading of the application domain and caches them for performance. If you need to update this cache, you need to call the Reloud() method as following &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;Properties.&lt;SPAN style="COLOR: teal"&gt;Settings&lt;/SPAN&gt;.Default.Reload(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;You can download the binary from &lt;A href="http://msharaf.members.winisp.net/files/ApplicationSettingsWriter.zip" mce_href="http://msharaf.members.winisp.net/files/ApplicationSettingsWriter.zip"&gt;here&lt;/A&gt; and the source code from &lt;A href="http://msharaf.members.winisp.net/files/ApplicationSettingsWriter-Source.zip" mce_href="http://msharaf.members.winisp.net/files/ApplicationSettingsWriter-Source.zip"&gt;here&lt;/A&gt;. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;Best regards, &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Tahoma"&gt;Mohamed &lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1491089" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /></entry><entry><title>Using application/user settings in C# 2.0</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2006/12/12/using-application-user-settings-in-c-2-0.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2006/12/12/using-application-user-settings-in-c-2-0.aspx</id><published>2006-12-12T10:53:00Z</published><updated>2006-12-12T10:53:00Z</updated><content type="html">&lt;P&gt;This is a quick post for using application or user settings in C# 2.0. I found most of the articles dealing with it in VB which is pretty easy. &lt;/P&gt;
&lt;P&gt;All you need to access a setting called "ServerName" in Visual Basic is this line &lt;/P&gt;
&lt;P&gt;My.Settings.ServerName="myServer" &lt;/P&gt;
&lt;P&gt;For more information about settings you can refer to MSDN @ &lt;A href="http://msdn2.microsoft.com/en-us/library/bc6ws923(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/bc6ws923(VS.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/bc6ws923(VS.80).aspx&lt;/A&gt; (all samples in VB) &lt;/P&gt;
&lt;P&gt;In C#, to access the application/user settings you need to use this line &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;String myserver=Properties.&lt;SPAN style="COLOR: teal"&gt;Settings&lt;/SPAN&gt;.Default.&lt;/SPAN&gt; &lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;myServer; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If you want to write to this &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;Properties.&lt;SPAN style="COLOR: teal"&gt;Settings&lt;/SPAN&gt;.Default.&lt;/SPAN&gt; &lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;myServer="myServer"; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;But take care that you can't change application settings in code. You can only change user settings. To change the application settings, you need to write your own code to open the configuration file as any xml file and modify it. I've written a simple component to do this which I'll post later this week. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1264835" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /></entry><entry><title>Misleading error message when you create foreign key constraint</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2006/12/12/misleading-error-message-when-you-create-foreign-key-constraint.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2006/12/12/misleading-error-message-when-you-create-foreign-key-constraint.aspx</id><published>2006-12-12T10:18:00Z</published><updated>2006-12-12T10:18:00Z</updated><content type="html">&lt;P&gt;When you create new foreign key constraint in SQL Server 2005 and this constraint conflict with the data already exists in the tables, you will get an error message that might be misleading. Let's say that you have 2 tables (depts and employee) and you want to create a foreign key constraint in the employee table that references the depts table. If you wrote this script &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;ALTER&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;TABLE&lt;/SPAN&gt; dbo&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;employees &lt;SPAN style="COLOR: blue"&gt;ADD&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;CONSTRAINT &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FK_employees_depts &lt;SPAN style="COLOR: blue"&gt;FOREIGN&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;KEY &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: gray"&gt;( &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;deptID &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;REFERENCES&lt;/SPAN&gt; dbo&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;depts &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: gray"&gt;( &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ID &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;ON&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;UPDATE&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;NO&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;ACTION&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;ON&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;DELETE&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;NO&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;ACTION &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;And you have a raw in the employee table that has deptID column with a value that doesn't have a match in the depts. Table, you will get this error message &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 8pt"&gt;The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_employees_depts". The conflict occurred in database "testing", table "dbo.depts", column 'ID'. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;You may think that the foreign key constraint created, not it's not. This error message equivalent to the this error message in SQL 2000 &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 8pt"&gt;Foreign key 'FK_employees_depts' references invalid column 'deptID' in referencing table 'employees'. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 8pt"&gt;Msg 1750, Level 16, State 0, Line 1 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 8pt"&gt;Could not create constraint. See previous errors. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;So you need to resolve data conflict in the table before creating the foreign key. &lt;/P&gt;
&lt;P&gt;Hope that helps &lt;SPAN style="FONT-FAMILY: Wingdings"&gt;J&lt;/SPAN&gt; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1264759" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term="SQL Server" scheme="http://blogs.msdn.com/mosharaf/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>How to add null value in Management Studio (SQL Server 2005)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2006/10/30/how-to-add-null-value-in-management-studio-sql-server-2005.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2006/10/30/how-to-add-null-value-in-management-studio-sql-server-2005.aspx</id><published>2006-10-30T11:00:00Z</published><updated>2006-10-30T11:00:00Z</updated><content type="html">&lt;P&gt;Updating database tables using Management Studio is a the easiest way during the development phase. If you do so, you probably need sometimes to update column to add a null value instead of the current value.&lt;/P&gt;
&lt;P&gt;To do so you just need to press CTRL+0&lt;/P&gt;
&lt;P&gt;It's also valid for Enterprise Manager for SQL 2000. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;Enjoy :)&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt; Mohamed Sharaf&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=902106" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term="SQL Server" scheme="http://blogs.msdn.com/mosharaf/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Using test certificate with Reporting Services 2005 to establish SSL connection</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2006/10/30/using-test-certificate-with-reporting-services-2005-to-establish-ssl-connection.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2006/10/30/using-test-certificate-with-reporting-services-2005-to-establish-ssl-connection.aspx</id><published>2006-10-30T10:08:00Z</published><updated>2006-10-30T10:08:00Z</updated><content type="html">&lt;P mce_keep="true"&gt;If you are planning to publish your Reporting Services site to the internet then you need to secure the communication between the server and the clients. The industry standard to do so is to buy an SSL certificate from a public certificate authority (CA) like &lt;A href="http://www.verisign.com/" mce_href="http://www.verisign.com/"&gt;VeriSign&lt;/A&gt;. This would cost you much money especially that you have to pay for each physical server.&lt;/P&gt;
&lt;P&gt;The other solution that would be appropriate if you are publishing your reports to your company's employees is to use a certificate issued by you or a "testing certificate". &lt;/P&gt;
&lt;P&gt;To do so you need to do the following steps&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;1. &lt;/B&gt;&lt;B&gt;Install Certificate Authority (CA) on this computer&lt;/B&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;By installing Certificate Authority Service (CA), you would behave like VeriSign so you can issue certificates to other if they requested a certificate from your server. To install Certificate Authority on Windows 2003, follow these steps&lt;/P&gt;
&lt;P&gt;Go to Control Panelà Add/ Remove programs à Add/ Remove windows components&lt;/P&gt;
&lt;P&gt;Check on Certificate Services and follow the steps or the wizard as following&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/InstallCA.GIF" mce_src="http://msharaf.members.winisp.net/Images/InstallCA.GIF"&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;a) Choose Stand-alone root CA because it's necessary for Reporting Services to trust the certificates issued from this CA. &lt;/LI&gt;&lt;BR&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/installCA2.GIF"&gt; 
&lt;LI&gt;b) Write the Common Name (CN) of the new CA.&lt;/LI&gt;&lt;BR&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/installCA3.GIF"&gt; 
&lt;LI&gt;c) The wizard will restart IIS and it's better to reboot the machine after installing the new CA&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;2. &lt;/B&gt;&lt;B&gt;Request a certificate using IIS MMC from this CA&lt;/B&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;From IIS, right click on the web site that has Reporting Services installed on it and choose properties. Open the "Directory Security" tab and press "Service Certificates" button.&lt;/P&gt;
&lt;P&gt;Choose "Create new Certificate" then Next&lt;/P&gt;
&lt;P&gt;From the second screen in the wizard choose "Prepare the request now but send it later" then click Next&lt;/P&gt;
&lt;P&gt;In the Name and security Settings page, write a name of your certificate.&lt;/P&gt;
&lt;P&gt;In the Organization Information page, write your company name and the department. &lt;/P&gt;
&lt;P&gt;In the "Your Site's Common Name" page, write the common name of your site. Take care of this step because it's very important this name should be the name of your site. i.e. if the site full name is Extranet.MyCompany.com so the common name should be Extranet.MyCompany.com &lt;/P&gt;
&lt;P&gt;At the end of this wizard, it will save the request in text file. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;3. &lt;/B&gt;&lt;B&gt;Issue the certificate&lt;/B&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Now, open the Certificate Authority (CA) console (Administrative tools à Certification Authority. &lt;/P&gt;
&lt;P&gt;Right click on the CA name in the console and choose "Submit new request"&lt;/P&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/CA_Issue.GIF"&gt; 
&lt;P&gt;Browse to the certificate request file that you created using IIS wizard and choose it.&lt;/P&gt;
&lt;P&gt;You will find it under bending Requests folder, right click on it and choose issue. You will find it under the Issued certificates folder.&lt;/P&gt;
&lt;P&gt;Right click on the certificate and choose "Export Binary Data". Choose cer extension to the file and save it.&lt;/P&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/exportcert.GIF"&gt; 
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;4. &lt;/B&gt;&lt;B&gt;Install Certificate on IIS&lt;/B&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Now Open again IIS management console and from "Directory Security" tab of the web site properties, choose "Server Certificate". In the wizard choose "Process the bending request and install certificate".&lt;/P&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/ssl-IISCertInstall1.gif"&gt; 
&lt;P&gt;Choose the file that you saved using Certificate Authority and complete the wizard.&lt;/P&gt;
&lt;P&gt;Now you have a certificate ready for you web site, if you want to restrict access to SSL connections only for the whole site or any particular web application, do the following.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From the web site/application properties choose directory security tab then in the "Secure Communication" box, choose Edit. Check require secure channel (SSL).&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;5. &lt;/B&gt;&lt;B&gt;Set the Reporting Services to use this Certificate&lt;/B&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Finally, you need to configure Reporting Services to work over SSL. &lt;/P&gt;
&lt;P&gt;Open Reporting Services Configuration from the SQL Server 2005 group.&lt;/P&gt;
&lt;P&gt;Choose Report Server Virtual Directory section. &lt;/P&gt;
&lt;P&gt;Mark the checkbox "Require Secure Socket Layer Connections (SSL)"&lt;/P&gt;
&lt;P&gt;In the "Require For" drop down, choose the appropriate method for your usage the description of them is&lt;/P&gt;
&lt;P&gt;1 - Connections only&lt;/P&gt;
&lt;P&gt;2 - Report data&lt;/P&gt;
&lt;P&gt;3 - Entire Web service API&lt;/P&gt;
&lt;P&gt;The levels are cumulative. Level 3 is the most secure&lt;B&gt; &lt;/B&gt;and 1 is the least secure one. Form more information about them please refer to &lt;A href="http://msdn2.microsoft.com/en-us/library/ms154709.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms154709.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms154709.aspx&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In the certificate name text box, add the certificate common name as you wrote in step 2 so it should be in our example Extranet.MyCompany.com&lt;/P&gt;
&lt;P&gt;Now restart the machine then begin your encrypted browsing J&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;6. &lt;/B&gt;&lt;B&gt;Side issues.&lt;/B&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I've faced some side issues during the implementation of SSL for Reporting Services 2005. Like the following&lt;/P&gt;
&lt;P mce_keep="true"&gt;You need to reboot the server after setting the certificate &lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI&gt;The common error message in SSL with reporting services is "&lt;I&gt;The underlying connection was closed: Could not establish secure channel for SSL/TLS&lt;/I&gt;" This error message means that the reporting web application code doesn't trust the certificate of the Reporting Services web service.&lt;/LI&gt;
&lt;UL type=circle&gt;
&lt;LI&gt;Note:&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;P&gt;When you browse the reporting web application, you actually are calling the XML Web Service of Reporting Service because the web application is calling it.&lt;/P&gt;
&lt;P&gt;That's why it's required to install the certificate as trusted certificate in all your servers if you have server farm.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;When you want to deploy your reports from your development machine to the server, the deployment fails with the error "&lt;I&gt;The underlying connection was closed: Could not establish secure channel for SSL/TLS&lt;/I&gt;"&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;You need also to install the certificate as trusted certificate in the development machine, the easiest way to do so is the following:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE cellSpacing=0 cellPadding=0 width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;OL type=1&gt;
&lt;LI&gt;Browse to the reporting site using IE&lt;/LI&gt;
&lt;LI&gt;Click on view certificate button in the warning window in case of IE6 or the red area at the top in case of IE 7 (see image below)&lt;/LI&gt;&lt;BR&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/IE.GIF"&gt; 
&lt;LI&gt;In the view certificate window, click on Install certificate&lt;/LI&gt;
&lt;LI&gt;In the certificate store screen, choose "Place all certificate in the following store"&lt;/LI&gt;
&lt;LI&gt;Click on browse and choose &lt;I&gt;Trusted root certificate authorities. &lt;/I&gt;You will get a warning that Microsoft can't trust this certificate, choose yes to install it.&lt;/LI&gt;
&lt;LI&gt;You now trust the certificate but you need also to trust the certificate authority which issued this certificate.&lt;/LI&gt;
&lt;LI&gt;Browse to the same site again (you may need to open another instance of IE) and click on view certificate then choose certificate path tab. This will show you the issuer of the certificate. Click on the issuer and choose view certificate (at the bottom) and install the issuer in the &lt;I&gt;Trusted root certificate authorities &lt;/I&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;You get a warning when you browse to the Reporting site from Internet Explorer.&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;You need to install the certificate as discussed earlier.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=901834" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term="SQL Server" scheme="http://blogs.msdn.com/mosharaf/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Are you using IE7 and have a problem in accessing some site?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2006/08/07/are-you-using-ie7-and-have-a-problem-in-accessing-some-site.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2006/08/07/are-you-using-ie7-and-have-a-problem-in-accessing-some-site.aspx</id><published>2006-08-07T18:05:00Z</published><updated>2006-08-07T18:05:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face=Tahoma&gt;&lt;A href="http://www.microsoft.com/windows/ie/default.mspx" mce_href="http://www.microsoft.com/windows/ie/default.mspx"&gt;&lt;FONT size=2&gt;Internet Explorer&lt;/FONT&gt; &lt;/A&gt;&lt;FONT size=2&gt;&lt;A href="http://www.microsoft.com/windows/ie/default.mspx" mce_href="http://www.microsoft.com/windows/ie/default.mspx"&gt;7&lt;/A&gt; is the newest version of Internet Explorer(IE) will be launched&amp;nbsp;on Windows&amp;nbsp;Vista time. It will also be available for XP SP2 and&amp;nbsp;2003 SP1&amp;nbsp;users. It has many fancy features like new rendering engine(you will love it especially in LCD screens), Built in RSS aggregator, new enhanced security model and new printing engine. You can try the Beta 3 now at &lt;A href="http://www.microsoft.com/windows/ie/downloads/default.mspx" mce_href="http://www.microsoft.com/windows/ie/downloads/default.mspx"&gt;http://www.microsoft.com/windows/ie/downloads/default.mspx&lt;/A&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Tahoma&gt;Some early testers faced a problem that they couldn't browse some sites they used to browse using IE 6 that's because these sites are searching for IE 6 user agent header. If you are using IE 7 then your user agent header will be like this &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1 face=Verdana&gt;User-Agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1 face=Tahoma&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Tahoma&gt;Overcoming this problem depend on who you are, are you a web developer who want to allow IE7 users to browse your site without a problem or you are a user that couldn't browse your favorite site after installing IE7.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;STRONG&gt;If you are a Web Developer:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2 face=Tahoma&gt;Please refer to MSDN article at &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/browserdetection.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/browserdetection.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/browserdetection.asp&lt;/A&gt;&amp;nbsp;titled "&lt;EM&gt;Detecting Internet Explorer More Effectively&lt;/EM&gt;"&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;STRONG&gt;If you are a user who installed IE7 and you want to browse your favorite sites like before:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Tahoma&gt;You need to change a key in your registry to make your IE 7 simulate the user-agent header of IE6. Fortunately, this is pretty simple. All you need is to run the reg file included in &lt;A href="http://www.fiddlertool.com/useragent.aspx" mce_href="http://www.fiddlertool.com/useragent.aspx"&gt;http://www.fiddlertool.com/useragent.aspx&lt;/A&gt;. Download and run the file in the link "Internet Explorer 6". Restart your IE and everything will work fine with you :)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Tahoma&gt;have a nice browsing,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Tahoma&gt;Mohamed Sharaf&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=691014" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/mosharaf/archive/tags/ASP.NET/default.aspx" /><category term="General" scheme="http://blogs.msdn.com/mosharaf/archive/tags/General/default.aspx" /></entry><entry><title>Adding custom code to Local Reports in Visual Studio.NET 2005 (Problems &amp; Solutions)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2005/12/20/LocalReportCustomCode.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2005/12/20/LocalReportCustomCode.aspx</id><published>2005-12-20T19:23:00Z</published><updated>2005-12-20T19:23:00Z</updated><content type="html">&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;If you are one of the people who used and enjoyed &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSGSTART/htm/gs_overview_v1_8ebd.asp?frame=true" mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSGSTART/htm/gs_overview_v1_8ebd.asp?frame=true"&gt;SQL Server Reporting Services &lt;/A&gt;(SSRS) in SQL 2000 and you wanted to use it in your windows/web applications without the server side components (just like what you are doing with Crystal Reports). So you would be much exited about the new &lt;A href="http://msdn2.microsoft.com/en-us/library/ms251671(en-US,VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms251671(en-US,VS.80).aspx"&gt;ReportViewer Controls&lt;/A&gt;. ReportViewer controls are two controls for Windows and Web applications that can either show &lt;A href="http://msdn2.microsoft.com/en-us/library/ms252075.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms252075.aspx"&gt;reports produced by SQL Server Reporting Services&lt;/A&gt; or process and &lt;A href="http://msdn2.microsoft.com/en-us/library/ms251704.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms251704.aspx"&gt;render reports locally&lt;/A&gt;.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;These reports are called Local Report and it's intended to provide reporting features without SSRS. You can use them without having a license for SSRS but be aware that you would lose some features like&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0cm" type=disc&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l3 level1 lfo1; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Report parameters in client report definitions (.rdlc) do not map to query parameters. There is no parameter input area in a client report definition that accepts values that are subsequently used in a query.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l3 level1 lfo1; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Client report definitions do not include embedded query information. You must define data sources that return ready-to-use data for the report. So you have to provide a DataSource for your report like a DataSet, DataTable…&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l3 level1 lfo1; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Browser-based printing through the RSClientPrint ActiveX control is not available for client report definitions that run in the ReportViewer Web server control. The print control is part of the report server feature set.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l3 level1 lfo1; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;You would loose all collaboration activities of SSRS like scheduling to send reports to some users at specific time&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt 18pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt 18pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;I used ReportViewer for Windows forms in small report in which I had to add custom code in it and I had some problems that I would like to share with you solutions for them. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt 18pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;First we would go quickly through the process of creating simple report as following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;1)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Create a new windows forms project and open its form. Drag the ReportViewer control from the Data tab as shown in the image below &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;IMG src="http://msharaf.members.winisp.net/Images/toolBarReport.GIF" mce_src="http://msharaf.members.winisp.net/Images/toolBarReport.GIF"&gt; 
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;2)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Use the smart tag tasks to dock the report in all the form (you can use properties window as well). Then from the smart tag choose "Design new report". If you didn't see this option you can simply create new report. From solution explorer, right click on the project name then choose "add new item" then choose report. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;3)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;The report file would have the extension "rdlc" not "rdl" as it would be in server reports.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;4)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Local Reports need to have a data source so go to Data Sources window and create your data source (let's say that it will get all Category name and description from categories table in Northwind)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;5)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;From the ToolBar window, drop a table inside the report &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;6)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;From the Data Source window, drag &amp;amp; drop the CategoryName and Description fields to the details row of the table. Now you finished creating the report. Let's bind it to the ReportViewer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;7)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Return back to the ReportViewer and from the smart tag menu choose, select your report name from the drop down menu.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -18pt; MARGIN: 0cm 0cm 0pt 36pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-fareast-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;8)&lt;FONT size=1 face="Times New Roman"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN dir=ltr&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Run the application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Now you have the report. Let's go to add custom code to the report.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;Why would you add custom code?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;You may want to add custom code to the report to do more actions than what's provided with the report functions. So it gives you a base for extending your report. You may want to add custom code to implement simple string manipulation task or sophisticated data access manipulation. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Cod added to Local Report can be one of two types:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;Embedded Code:&lt;/SPAN&gt;&lt;/B&gt; Added directly inside the rdlc file. If you open the file in notepad, you can see the code inside the &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=maroon size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Code&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;tag.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;Custom Assemblies:&lt;/SPAN&gt;&lt;/B&gt; You can add a reference in external assembly and use functions inside it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;How to add a custom code in a local report?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;According to &lt;A href="http://msdn2.microsoft.com/en-us/library/ms252130.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms252130.aspx"&gt;MSDN library&lt;/A&gt;, you add it as following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;Embedded Code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0cm" type=1&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;On the Report menu, click Report Properties. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;On the Code tab, in Custom code, type the code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;Custom Assemblies:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0cm" type=1&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l2 level1 lfo4; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;On the Report menu, click Report Properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l2 level1 lfo4; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;On the References tab, do the following: &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l2 level1 lfo4; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;In References, click the add (...) button and then select or browse to the assembly from the Add Reference dialog box.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l2 level1 lfo4; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;In Classes, type name of the class and provide an instance name to use within the report. That's in the case of instance members, in the case of static (shared in VB) members, you don't need to add anything in Classes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;What's the code that I can add?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;You can add class members only (properties, methods, fields) but you can't add classes because these members are encapsulated in a class at runtime, this class called &lt;I&gt;&lt;SPAN style="FONT-STYLE: italic"&gt;Code &lt;/SPAN&gt;&lt;/I&gt;class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Take a look at this code snippet. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Public&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;ReadOnly&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Property&lt;/SPAN&gt;&lt;/FONT&gt; getSomeData() &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Get&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt;&lt;/FONT&gt; sharedMember&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Get&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt;&lt;/FONT&gt; sharedMember &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;&lt;/FONT&gt; = &lt;FONT color=maroon&gt;&lt;SPAN style="COLOR: maroon"&gt;"Omar"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT color=maroon size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt;&lt;/FONT&gt; toUpperCase(&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt;&lt;/FONT&gt; s &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;&lt;/FONT&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt;&lt;/FONT&gt; conn &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt;&lt;/FONT&gt; System.Data.SqlClient.SqlConnection()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt;&lt;/FONT&gt; s.toUpper()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;You can use this code inside a textBox or a table column as following &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;=Code.toUpperCase(Code.getSomeData)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;What are the namespaces that I can use inside my custom code?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;All .NET namespaces can be used inside your custom code but be aware that by default only &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;Microsoft.VisualBasic&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;, &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;System.Convert&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;, and &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;System.Math&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt; namespaces are referenced inside your reporting custom code. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Now let's jump into the problems. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;Adding code that uses types that are not in these namespaces (Microsoft.VisualBasic, System.Convert, and System.Math)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Let's say that you are using a code that access SQL Server database to get some data to use it inside your report. You are using SqlConnection in your code. You would receive an error like this&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;I&gt;&lt;FONT color=green size=2 face=Tahoma&gt;&lt;SPAN style="FONT-STYLE: italic; FONT-FAMILY: Tahoma; COLOR: green; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;There is an error on line 9 of custom code: [BC30002] Type 'System.Data.SqlClient.SqlConnection' is not defined.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Because System.Data.SqlClient resides in the System.Data.dll assembly and this assembly is not referenced by default by the report custom code. To solve this problem you need to add a reference to the System.Data.dll assembly in the References tag in the report properties window. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;But this is not the end of the story; you would face another problem which described in the next step&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;How to make an assembly trusted for your report code&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Because Local Reports like SQL Server Reporting Services reports are written using open format (Report Definition Language (RDL)). Any user can add any code or reference any assembly from your rdl file at the production environment which would cause a BIG security hole. You need to mark these assemblies as trusted inside your Windows Application code. Or you would get an error like this &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;I&gt;&lt;FONT color=green size=2 face=Tahoma&gt;&lt;SPAN style="FONT-STYLE: italic; FONT-FAMILY: Tahoma; COLOR: green; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;The report references the code Module 'System.Data, Version=2.0.0.0, Culture=neutral, Publickey Token=b77a5XXXXXXXX', which is not a trusted assembly&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;You need to use the &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.addtrustedcodemoduleincurrentappdomain.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.addtrustedcodemoduleincurrentappdomain.aspx"&gt;AddTrustedCodeModuleInCurrentAppDomain&lt;/A&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;/FONT&gt;method of the &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.aspx"&gt;LocalReport&lt;/A&gt; class. You can add the following line at the Form_load event handler of your windows application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;this&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;.reportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(&lt;FONT color=maroon&gt;&lt;SPAN style="COLOR: maroon"&gt;"System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/SPAN&gt;&lt;/FONT&gt;); &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;And again it's not the end of the story; you will face another problem ;). Please be patient with me because I faced all these problems sequentially and I didn't find any resources to help me.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;What are the Code Access Security (CAS) permissions assigned to any code running inside LocalReport by default&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;By default the only permission bound to the code running inside the LocalReport is &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;ExecutePermission&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt; So your code can't access file system, databases, registry… unless you give it explicitly the required permissions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;For example, if you are trying to connect to a database from your code, you will get this error &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;I&gt;&lt;FONT color=green size=2 face=Tahoma&gt;&lt;SPAN style="FONT-STYLE: italic; FONT-FAMILY: Tahoma; COLOR: green; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Request of the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089' failed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;To give the assemblies running in the report the appropriate permissions, you need to use the &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.executereportincurrentappdomain.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.executereportincurrentappdomain.aspx"&gt;ExecuteReportInCurrentAppDomain&lt;/A&gt; Method of the &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.aspx"&gt;LocalReport&lt;/A&gt; class. Which causes the expressions in the report to be executed inside the current appDomain instead of executing them in a sandbox. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;The &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;ExecuteReportInCurrentAppDomain&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt; method takes one parameter of the type &lt;A href="http://msdn2.microsoft.com/en-us/library/system.appdomain.evidence.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.appdomain.evidence.aspx"&gt;Evidence&lt;/A&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;In the following example I'm using the evidence associated with my current appDomain so the report code will have all permissions that I have in my application&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;this&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;.reportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(&lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;AppDomain&lt;/SPAN&gt;&lt;/FONT&gt;.CurrentDomain.Evidence);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;By working on these steps, your code will run smoothly inside your report. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;For the people who are trying to move their code in separated assembly and reference it from their report, they would face another problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;If you are following the steps mentioned in MSDN regarding how to reference custom code (mentioned above). You will end up with this message &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;I&gt;&lt;FONT color=green size=2 face=Tahoma&gt;&lt;SPAN style="FONT-STYLE: italic; FONT-FAMILY: Tahoma; COLOR: green; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Error while loading code module: ‘ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Details: Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;After a lot of trials with this error, I found that I have to do the following.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0cm" type=1&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; COLOR: green; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT color=black size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; COLOR: windowtext; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Select the report file from Solution Explorer, Go to Properties Window and change its &lt;/SPAN&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;BuildAction&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT color=black size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; COLOR: windowtext; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt; to &lt;/SPAN&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold; mso-bidi-font-family: 'Times New Roman'"&gt;Content&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;Set &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;Copy to output Directory&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt; property to &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;Copy always&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt; or Copy if newer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;In the form designer class (the partial class created by Visual Studio according to naming schema &amp;lt;FormName&amp;gt;.Designer.CS or &amp;lt;FormName&amp;gt;.Designer.VB) replace the line which instruct the &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;ReportViewer&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt; to load the report file from resource file with another line that instruct the &lt;B&gt;&lt;FONT color=green&gt;&lt;SPAN style="COLOR: green; FONT-WEIGHT: bold"&gt;ReportViewer&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt; to load the report from current directory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;So this line &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="TEXT-INDENT: 36pt; MARGIN: 0cm 0cm 0pt 36pt" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;this&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;.reportViewer1.LocalReport.ReportEmbeddedResource = &lt;FONT color=maroon&gt;&lt;SPAN style="COLOR: maroon"&gt;"testLocalReport.Report1.rdlc"&lt;/SPAN&gt;&lt;/FONT&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0cm" type=1 start=5&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;With this line&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="TEXT-INDENT: 36pt; MARGIN: 0cm 0cm 0pt 36pt" dir=ltr class=MsoNormal&gt;&lt;FONT color=blue size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;this&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;.reportViewer1.LocalReport.ReportPath = &lt;FONT color=maroon&gt;&lt;SPAN style="COLOR: maroon"&gt;"Report1.rdlc"&lt;/SPAN&gt;&lt;/FONT&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0cm" type=1 start=6&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Copy the dll that you are referencing to the Debug or Release directory of your application&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0cm 0cm 0pt; mso-list: l4 level1 lfo5; tab-stops: list 36.0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Make the line that executes the report in the current appDomain first, then add the lines that trust the referenced assembly and all assemblies referenced by this assembly (see above)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;I hope this would help you to really enjoy VS 2005 features &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;//Mohamed &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" dir=ltr class=MsoNormal&gt;&lt;FONT size=2 face=Tahoma&gt;&lt;SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=505945" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /><category term="SQL Server" scheme="http://blogs.msdn.com/mosharaf/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Encrypting configuration files using protected configuration</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mosharaf/archive/2005/11/17/protectedConfiguration.aspx" /><id>http://blogs.msdn.com/mosharaf/archive/2005/11/17/protectedConfiguration.aspx</id><published>2005-11-17T19:57:00Z</published><updated>2005-11-17T19:57:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;One of the cool security features in ASP.NET 2.0 is the ability to parts of web.config. Web.config encryption uses &lt;A href="http://www.w3.org/TR/xmlenc-core/"&gt;XML encryption standards&lt;/A&gt; at its core. &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Protected configuration uses a class derived from the abstract class &lt;B&gt;&lt;I&gt;ProtectedConfigurationProvider&lt;/I&gt;&lt;/B&gt;. .NET framework has shipped with two providers &lt;B&gt;&lt;I&gt;RSAProtectedConfigurationProvider&lt;/I&gt;&lt;/B&gt; which uses TripleDES and &lt;A href="http://www.di-mgt.com.au/rsa_alg.html"&gt;RSA encryption&lt;/A&gt; and &lt;B&gt;&lt;I&gt;DPAPIProtectedConfigurationProvider&lt;/I&gt;&lt;/B&gt; which uses Windows Data Protection API (DPAPI)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;For more comprehensive information about this topic, please refer to &lt;A href="http://msdn2.microsoft.com/en-us/library/53tyfkaw.aspx"&gt;MSDN&lt;/A&gt; &lt;B&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Protected configuration in action:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;One of the most common uses of the protected configuration is to encrypt connection strings in web.confg (that's one of the reasons for creating a separate tag for connection strings instead of adding it in appSettings tag). &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Let's say we have a connection string tag like this&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&amp;lt;connectionStrings&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&amp;lt;add name="advWorks" connectionString="Data Source=.\yukon;Initial Catalog=AdventureWorks;User ID=webUser;pwd=my_P@ssw0rd" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&amp;lt;/connectionStrings&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Adding this connection string as plain text is not the best practice for web application security and this might cause serious hacking problems. To encrypt this tag only, you could use the encryption classes in .NET framework or use the handy tool &lt;B&gt;&lt;I&gt;ASPNet_regiis.exe&lt;/I&gt;&lt;/B&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Assuming that this application located in http://localhost/testwebCS2, we could use &lt;B&gt;&lt;I&gt;ASPNet_regiis.exe&lt;/I&gt;&lt;/B&gt; as following&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 11pt; mso-bidi-language: AR-EG"&gt;aspnet_regiis -pe connectionStrings -app /testwebcs2&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;This line will use &lt;B&gt;&lt;I&gt;RSAProtectedConfigurationProvider&lt;/I&gt;&lt;/B&gt; to encrypt the tag connectionStrings in the application called /testwebCS2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Then this tag would be as following (I omitted most of the cipher base64 strings to preserve space)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;connectionStrings&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;configProtectionProvider&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;RsaProtectedConfigurationProvider&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;EncryptedData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/04/xmlenc#Element&lt;/SPAN&gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/04/xmlenc#&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;EncryptionMethod&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Algorithm&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/04/xmlenc#tripledes-cbc&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;KeyInfo&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2000/09/xmldsig#&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;EncryptedKey&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/04/xmlenc#&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;EncryptionMethod&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Algorithm&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/04/xmlenc#rsa-1_5&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;KeyInfo&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2000/09/xmldsig#&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;KeyName&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Rsa Key&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;KeyName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;KeyInfo&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CipherData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CipherValue&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;YojkA1KgIR1nnThk=&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;CipherValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CipherData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;EncryptedKey&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;KeyInfo&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CipherData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CipherValue&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;8h+tauv00O52DdGHFKSv =&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;CipherValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CipherData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;EncryptedData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;connectionStrings&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;As you can see in the previous XML, the data itself encrypted using the symmetric encryption algorithm called Triple DES. The key used to encrypt the data is embedded but it's also encrypted using RSA.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;But where's the key to decrypt that key?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Good question :). The &lt;B&gt;&lt;I&gt;RsaProtectedConfigurationProvider&lt;/I&gt;&lt;/B&gt; uses the machine account or the user account to encrypt the keys and save them in a file which called "key container". To use the protected configuration with ASP.NET we should not use the user account to encrypt the keys because we need to be logged in with that user to be able to open that key container. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Key container for the machine account usually saved in C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA. And the ASP.NET worker process identity (ASPNET user in XP/2000 or Network Service in case of 2003) should have access to these files to be able to decrypt it or you would get this error message&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 11pt; mso-bidi-language: AR-EG"&gt;"Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;Fortunately the ASPNet_regiis tool gives us the option to add users to the ACL of the key containers using the –pa parameter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;For example to give access to the ASPNET user &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 11pt; mso-bidi-language: AR-EG"&gt;aspnet_regiis -pa "&amp;lt;key container name&amp;gt;" "ASPNET"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;So, how to get the key container name?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;By searching in machine.config (usually in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG) we would find this section&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;configProtectedData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;defaultProvider&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;RsaProtectedConfigurationProvider&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;providers&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;add&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;name&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;RsaProtectedConfigurationProvider&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Uses RsaCryptoServiceProvider to encrypt and decrypt&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="COLOR: red"&gt;keyContainerName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;NetFrameworkConfigurationKey&lt;/SPAN&gt;"&lt;/B&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;cspProviderName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;""&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;useMachineContainer&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;useOAEP&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;add&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;name&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;DataProtectionConfigurationProvider&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;System.Configuration.DpapiProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Uses CryptProtectData and CryptUnProtectData Windows APIs to encrypt and decrypt&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;useMachineProtection&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;keyEntropy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;""&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;providers&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;configProtectedData&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;The keycontainerName of the RsaProtectedConfigurationProvider is "NetFrameworkconfigurationKey" (it's good practice to change it in the production servers). So the aspnet_regiis would be as following&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 11pt; mso-bidi-language: AR-EG"&gt;aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;What if I'm using a server farm?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma; mso-bidi-language: AR-EG"&gt;In the server farms environment, you can simple use aspnet_regiis to create and export key container to distribute it to the whole server farm.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=493950" width="1" height="1"&gt;</content><author><name>Mohamed Sharaf</name><uri>http://blogs.msdn.com/members/Mohamed+Sharaf.aspx</uri></author><category term=".NET Framework" scheme="http://blogs.msdn.com/mosharaf/archive/tags/.NET+Framework/default.aspx" /><category term="ASP.NET" scheme="http://blogs.msdn.com/mosharaf/archive/tags/ASP.NET/default.aspx" /></entry></feed>