<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.iis.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:cs="http://blogs.iis.net/"><channel><title>Search results matching tags 'Code' and 'Microsoft'</title><link>http://blogs.iis.net/search/SearchResults.aspx?o=DateDescending&amp;tag=Code,Microsoft&amp;orTags=0</link><description>Search results matching tags 'Code' and 'Microsoft'</description><dc:language>en-US</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Improving Time-Critical Code written in C</title><link>http://blogs.iis.net/tomchris/archive/2008/09/02/improving-time-critical-code-written-in-c.aspx</link><pubDate>Tue, 02 Sep 2008 10:00:33 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:2595111</guid><dc:creator>Anonymous</dc:creator><cs:applicationKey>tomchris</cs:applicationKey><description>&lt;p&gt;Writing web pages is very similar to writing any other type of code.&amp;#160; You have to understand how it is going to be used and where you need to really make things run as quickly as possible.&lt;/p&gt;  &lt;p&gt;There are a number of tips on this blog already that deal with managed code and ways to optimize it.&amp;#160; But one of the things that we don't look at as often are other areas of code that we are dependant on.&amp;#160; For example, if you P/Invoke a native function, whatever it is doing, is something that you need to be aware of.&amp;#160; Because there is a lot of native functionality that is still available to us, I wanted to remind everyone of some of the tips you can use when dealing with C/C++ code.&lt;/p&gt;  &lt;p&gt;A great place to start is with: &lt;a title="http://msdn.microsoft.com/en-us/library/eye126ky.aspx" href="http://msdn.microsoft.com/en-us/library/eye126ky.aspx"&gt;Tips for Improving Time-Critical Code&lt;/a&gt;.&amp;#160; While most of these things don't apply to .NET based code, they are all very important when working with native code.&amp;#160; Another useful thing to be aware of is what the compiler can do for you.&amp;#160; For example, take a look at &lt;a title="http://msdn.microsoft.com/en-us/library/aa290055.aspx" href="http://msdn.microsoft.com/en-us/library/aa290055.aspx"&gt;Optimizing Your Code with Visual C++&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Feel free to add your own tips or pointers here.&amp;#160; I'd like to get a good collection going and then I can share that out as well.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8916635" width="1" height="1"&gt;</description></item><item><title>Visual Studio Designer not Respecting Assembly Binding Redirection</title><link>http://blogs.iis.net/tomchris/archive/2008/04/24/visual-studio-designer-not-respecting-assembly-binding-redirection.aspx</link><pubDate>Thu, 24 Apr 2008 19:16:33 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:2319889</guid><dc:creator>Anonymous</dc:creator><cs:applicationKey>tomchris</cs:applicationKey><description>&lt;p&gt;So we recently came across an issue where Visual Studio 2005 and 2008 Designers were not respecting assembly binding redirection.&lt;/p&gt;  &lt;h3&gt;Scenario&lt;/h3&gt;  &lt;p&gt;We have a file which is now version 2 and stored in the &lt;a href="http://msdn2.microsoft.com/en-us/library/yf1d93sz.aspx"&gt;GAC&lt;/a&gt;.&amp;#160; So the assembly version is 2.0.0.0.&amp;#160; We have some existing customers using version 1 so we want to be able to use &lt;a href="http://msdn2.microsoft.com/en-us/library/2fc472t2.aspx"&gt;Assembly Binding Redirection&lt;/a&gt; to point them to the new version of the assembly.&lt;/p&gt;  &lt;p&gt;For more information on configuring this, check out &lt;a href="http://msdn2.microsoft.com/en-us/library/433ysdt1.aspx"&gt;Configuring Assembly Binding Redirection&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The web page has code like:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tc:TestContacts&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;QuickContacts1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tc:AContact&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Test Tester&amp;quot;&lt;/span&gt; 
        &lt;span class="attr"&gt;Email&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;test@test.com&amp;quot;&lt;/span&gt; 
        &lt;span class="attr"&gt;Phone&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;(999) 555-1212&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tc:AContact&lt;/span&gt; &lt;span class="attr"&gt;Email&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;no@spam.thx&amp;quot;&lt;/span&gt; 
        &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Mr. A. Nonymous&amp;quot;&lt;/span&gt; 
        &lt;span class="attr"&gt;Phone&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;(999) 555-1234&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tc:TestContacts&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;We also have a Register Assembly line at the top that points to the 1.0.0.0 version of the file.&amp;#160; And we have an entry in our web.config that looks like this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;runtime&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;assemblyBinding&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;urn:schemas-microsoft-com:asm.v1&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;dependentAssembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;assemblyIdentity&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Tester1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;publicKeyToken&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;6ace53ab3256c766&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;bindingRedirect&lt;/span&gt; &lt;span class="attr"&gt;oldVersion&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0.0.0-1.1.0.0&amp;quot;&lt;/span&gt;
                             &lt;span class="attr"&gt;newVersion&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2.0.0.0&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;dependentAssembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;assemblyBinding&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;runtime&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;We could have done this in a policy file and got the same results.&amp;#160; So now we open this file in Design view inside Visual Studio and change a property of the TestContacts control.&amp;#160; For instance, adding an AccessKey.&amp;#160; Switching back to the Source view, we will now see:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tc:TestContacts&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;QuickContacts1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;samples.aspnet.cs.controls.acontact&lt;/span&gt; Name=&amp;quot;Test Tester&amp;quot; 
        Email=&amp;quot;test@test.com&amp;quot; 
        Phone=&amp;quot;(999) 555-1212&amp;quot; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;samples.aspnet.cs.controls.acontact&lt;/span&gt; Email=&amp;quot;no@spam.thx&amp;quot; 
        Name=&amp;quot;Mr. A. Nonymous&amp;quot; 
        Phone=&amp;quot;(999) 555-1234&amp;quot; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tc:TestContacts&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This breaks the site and it no longer works.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: Assembly Binding Redirection works find in other scenarios, it just doesn’t work right inside the Designer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Resolutions&lt;/h3&gt;

&lt;p&gt;There are two ways to resolve this issue.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Don’t use Assembly Binding Redirection at all and just leave the 1.0.0.0 version of the file in the GAC.&amp;#160; You will see a lot of .NET files do this, there are versions for .NET 1.0, 1.1, 2.0, etc all inside the GAC at the same time. &lt;/li&gt;

  &lt;li&gt;Change the existing files so that the Register Assembly line at the top of the web page points to the 2.0.0.0 version of the file. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep in mind that this is only a problem if you are actively changing the older files already, if you don’t touch the file it will be fine since this issue is only with the Designer.&amp;#160; So since you are already updating the file, it is trivial to update this line also.&lt;/p&gt;

&lt;p&gt;We are looking into this issue also, so there may be another resolution posted in the future.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f24%2fvisual-studio-designer-not-respecting-assembly-binding-redirection.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2ftom%2farchive%2f2008%2f04%2f24%2fvisual-studio-designer-not-respecting-assembly-binding-redirection.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8422491" width="1" height="1"&gt;</description></item></channel></rss>