<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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/"><channel><title>.NET Security Blog : Visual Studio</title><link>http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx</link><description>Tags: Visual Studio</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Visual Studio 10 Security Tab Changes</title><link>http://blogs.msdn.com/shawnfa/archive/2009/05/28/visual-studio-10-security-tab-changes.aspx</link><pubDate>Thu, 28 May 2009 17:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9644742</guid><dc:creator>shawnfa</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/9644742.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=9644742</wfw:commentRss><description>&lt;p&gt;Kris Makey, who works on the Visual Studio team, has written up a good blog post about the &lt;a href="http://blogs.msdn.com/krimakey/archive/2009/05/20/where-did-my-permission-set-controls-go.aspx"&gt;changes you’ll see on the security tab in Visual Studio 10 when it comes to editing permission sets&lt;/a&gt;.&amp;#160; He covers what the changes are, and some of the reasons why we worked with the Visual Studio team to make those changes.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9644742" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CLR+v4/default.aspx">CLR v4</category></item><item><title>Column Guides in Visual Studio</title><link>http://blogs.msdn.com/shawnfa/archive/2006/07/07/659281.aspx</link><pubDate>Fri, 07 Jul 2006 10:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:659281</guid><dc:creator>shawnfa</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/659281.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=659281</wfw:commentRss><description>&lt;P&gt;A lot of coding guidelines specify the maximum length for a line of code. For instance in the CLR, we like to keep lines of code under 110 characters long. Visual Studio has a feature which lets you display a vertical line at the column of your choosing to help visually see when a line is getting too long. This does involve mucking in the registry so the usual disclaimers apply. &lt;/P&gt;
&lt;P&gt;To enable this feature, set: &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 2em; FONT-SIZE: x-small; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace; BACKGROUND-COLOR: lightgrey; WORD-WRAP: break-word"&gt;[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor] &lt;BR&gt;"Guides"="RGB(192,192,192) 110" &lt;/DIV&gt;
&lt;P&gt;The values passed to the RGB function let you specify the color of the line, and the number following tells Visual Studio at what column to display it. The settings above create a code editing window similar to: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/photos/shawnfa/picture659277.aspx" target=_blank&gt;&lt;IMG src="http://blogs.msdn.com/photos/shawnfa/images/659277/637x480.aspx" border=0&gt;&lt;/A&gt;&lt;BR&gt;(Click the image for a better look). &lt;/P&gt;
&lt;P&gt;You can also create multiple guidelines by adding additional column numbers after the first one.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=659281" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Visual Studio Tip: Editing Project Files</title><link>http://blogs.msdn.com/shawnfa/archive/2006/04/26/582326.aspx</link><pubDate>Wed, 26 Apr 2006 17:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:582326</guid><dc:creator>shawnfa</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/582326.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=582326</wfw:commentRss><description>&lt;P&gt;Earlier I mentioned &lt;A HREF="/shawnfa/archive/2006/04/24/582278.aspx"&gt;tweaking project files&lt;/A&gt;&amp;nbsp;-- something that a lot of people do just by opening the project file up in Notepad and tweaking it.&amp;nbsp; Although it's a bit hard to discover, you can actually do this right within Visual Studio 2005, saving you from switching between applications, and more importantly buying you color coding and intellisense on the project file.&lt;/P&gt;
&lt;P&gt;To enable this, first right click on the project in Solution Explorer and choose "Unload Project".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Unload a project in Visual Studio" src="/photos/shawnfa/images/582320/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;This will cause the project node to grey out and be marked unavailable.&amp;nbsp; You can now right click on it and choose "Edit &amp;lt;project file name&amp;gt;", which opens the project file up in the Visual Studio XML editor and loads the MSBuild schema up for you.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Edit a project in Visual Studio" src="/photos/shawnfa/images/582322/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;Once you've made your changes, save the file, right click the project again and chose Reload Project.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Reload a project in Visual Studio" src="/photos/shawnfa/images/582324/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;Visual Studio will prompt you to close the project document, and&amp;nbsp;assuming there are no errors in the file, the project will reload and your changes will take effect.&amp;nbsp; If there was an error, Visual Studio will give you a dialog indicating which line and column the error was in and a brief description of what went wrong.&lt;/P&gt;
&lt;P&gt;In addition to using this for accessing features not available via the UI (as I mentioned in the strong name key post), I also tweak project files to invoke some custom MSBuild tasks that I use in personal projects.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=582326" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Sharing a Strong Name Key File Across Projects</title><link>http://blogs.msdn.com/shawnfa/archive/2006/04/24/582278.aspx</link><pubDate>Mon, 24 Apr 2006 20:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:582278</guid><dc:creator>shawnfa</dc:creator><slash:comments>30</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/582278.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=582278</wfw:commentRss><description>&lt;P&gt;v2.0 of the .NET Framework &lt;A HREF="/shawnfa/archive/2004/04/15/114258.aspx"&gt;deprecated the use of the AssemblyKeyFileAttribute and AssemblyKeyContainerAttribute&lt;/A&gt;.&amp;nbsp; Often times, these attributes were used to share a common key file across several projects.&lt;/P&gt;
&lt;P&gt;If you try to share key files using the Visual Studio 2005 &amp;lt;Browse ...&amp;gt; function on the signing property page, you'll find that the key file is copied into your project directory.&amp;nbsp; In a lot of cases this is exactly the desired behavior since it helps to&amp;nbsp;group all of the artifacts that go into building your project into one location.&amp;nbsp; However, it is a common requirement that the key file not be copied into every project directory and instead referenced from a single common location.&amp;nbsp; You can still pull this off using Visual Studio 2005:&lt;/P&gt;
&lt;P&gt;Step 1: Add&amp;nbsp;the key file to your project using the Add Existing Item menu.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Add an existing item to the project" src="/photos/shawnfa/images/582253/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;Step 2: In the add dialog, instead of choosing to add the key directly (which will make a copy into your project directory), hit the arrow next to the Add button and choose to add the key as a link.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Add a link to the key" src="/photos/shawnfa/images/582254/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;Step 3: Go to&amp;nbsp;the signing page of the project&amp;nbsp;properties.&amp;nbsp; Your key file should now be on the drop down list of available keys.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Select the key on the signing page" src="/photos/shawnfa/images/582255/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;Since the key is already a part of the project, Visual Studio will not &amp;nbsp;make a new copy of it.&amp;nbsp; One thing to notice, Visual Studio will reference your key as a relative path from the project file.&amp;nbsp; This may be exactly what you want -- but if you'd rather have a hard coded path, you can open up the project file and change the AssemblyOriginatorKeyFile (and the Include path of the Link to your key).&lt;/P&gt;
&lt;P&gt;You'll also want to make sure that on the property sheet of the key file, the Build Action is set to None and Copy to Output Directory is set to "Do not copy" -- You don't want to accidentally start distributing your key file as an embedded resource!&lt;/P&gt;
&lt;P&gt;Finally,&amp;nbsp;there are a couple of&amp;nbsp;tweaks you can make for asthetics.&amp;nbsp;After setting up signing, some people like to&amp;nbsp;add the key as a solution item, then edit the project files and add a &amp;lt;Visible&amp;gt;False&amp;lt;/Visible&amp;gt; tag to the None tag including&amp;nbsp;the key.&amp;nbsp; This presents the key in the Solution Explorer at the solution level rather than in each individual project.&lt;/P&gt;
&lt;P&gt;Personally, I like to see the key file that each assembly will be signed with, but I don't want it cluttering the root level of the project's files.&amp;nbsp; The tweak I make is to edit the project files and change the Link tag to have a Properties prefix.&amp;nbsp; For instance, I might have:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 2em; FONT-SIZE: x-small; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace; BACKGROUND-COLOR: lightgrey; WORD-WRAP: break-word"&gt;&amp;lt;ItemGroup&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;None Include="..\App.snk"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Link&amp;gt;Properties\App.snk&amp;lt;/Link&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/None&amp;gt;&lt;BR&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;This puts the key in the properties node of the project, which I think is a more appropriate location for it than the project root.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=582278" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/StrongName/default.aspx">StrongName</category></item><item><title>SN v2.0 Works With PFX Files</title><link>http://blogs.msdn.com/shawnfa/archive/2006/02/14/531921.aspx</link><pubDate>Tue, 14 Feb 2006 20:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:531921</guid><dc:creator>shawnfa</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/531921.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=531921</wfw:commentRss><description>&lt;P&gt;One enhancement to the v2.0 SN tool that may not get noticed right away is that it now has the ability to work with PKCS #12 PFX files in addition to SNK files.&amp;nbsp; The logic here is that a self signed certificate stored in a PFX file is the moral equivalent of an SNK key, except that it gives you the added benefit of storing your key in encrypted form rather than in the SNK's plain text format.&lt;/P&gt;
&lt;P&gt;This feature should be entirely transparent --&amp;nbsp;anywhere that SN takes a key file as input, you can now specify a PFX file instead. SN will detect this and prompt you for a password:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 2em; FONT-SIZE: x-small; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace; BACKGROUND-COLOR: lightgrey; WORD-WRAP: break-word"&gt;C:\Build&amp;gt;sn -R DelaySigned.exe KeyPair.pfx&lt;BR&gt;&lt;BR&gt;Microsoft (R) .NET Framework Strong Name Utility Version 2.0.50727.42&lt;BR&gt;Copyright (c) Microsoft Corporation. All rights reserved.&lt;BR&gt;&lt;BR&gt;Enter the password for the PKCS#12 key file:&lt;BR&gt;Assembly 'DelaySigned.exe' successfully re-signed&lt;BR&gt;&lt;/DIV&gt;
&lt;P&gt;Your password will not echo to the screen as you type it.&lt;/P&gt;
&lt;P&gt;There are a few limitations to this feature however.&amp;nbsp; Since it was designed with self signed certificates in mind, SN will not accept a PFX file which contains multiple certificates (there's no way to tell it which certificate you wish to use).&lt;/P&gt;
&lt;P&gt;Also, SN will not allow you to redirect standard input and load the password from a pipe.&amp;nbsp; (In this case it gives a rather cryptic error message "Failed to parse the PKCS#12 blob in KeyPair.pfx -- The handle is invalid."&amp;nbsp; ... we'll replace that message with something a bit more descriptive in a future release).&lt;/P&gt;
&lt;P&gt;Finally, the PFX file must have a password, even if that password is blank.&amp;nbsp; SN will never attempt to read a certificate with a NULL password.&lt;/P&gt;
&lt;P&gt;If you want to create a self signed PFX key, the easiest way is to use Visual Studio 2005.&amp;nbsp; In the project properties Signing tab, tell Visual Studio to create a new strong name key file.&amp;nbsp; VS will show you this dialog:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="/photos/shawnfa/images/531913/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;Selecting "Protect my key file with a password", the default option, creates a PFX file.&amp;nbsp; If you uncheck that option, you'll create a traditional SNK file.&amp;nbsp; VS will enforce that your password be at least six characters long.&amp;nbsp; It also provides the ability for you to change the password of an existing key pair.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=531921" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/StrongName/default.aspx">StrongName</category></item><item><title>Debugging Lightweight CodeGen in VS</title><link>http://blogs.msdn.com/shawnfa/archive/2005/10/25/484875.aspx</link><pubDate>Wed, 26 Oct 2005 01:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:484875</guid><dc:creator>shawnfa</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/484875.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=484875</wfw:commentRss><description>Haibo just &lt;a href="http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx"&gt;posted&lt;/A&gt; about his &lt;A href="http://gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=22BA8210-B3A0-4580-B362-ABC7C1A59C65"&gt;debugger visualizer for dynamic methods&lt;/A&gt;.&amp;nbsp; This is a pretty sweet piece of code for anyone who uses lightweight code generation and needs to debug the code they've emitted.&amp;nbsp; Basically it adds a visualizer to DynamicMethod objects that enables you to dump out the IL of that method.&amp;nbsp; (He also &lt;a href="http://blogs.msdn.com/haibo_luo/archive/2005/10/02/476242.aspx"&gt;explains the code he uses to convert from IL bytes to ILDasm style representation&lt;/A&gt;, which can be used with the new &lt;A href="http://msdn2.microsoft.com/en-us/library/system.reflection.methodbody"&gt;MethodBody&lt;/A&gt;&amp;nbsp;class that reflection exposes) 
&lt;P&gt;&lt;IMG alt="Lightweight CodeGen Visualizer" src="http://static.flickr.com/33/51647547_d174fdba98_o.gif"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=484875" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>New Security Features in Visual Studio 2005</title><link>http://blogs.msdn.com/shawnfa/archive/2005/10/06/477866.aspx</link><pubDate>Thu, 06 Oct 2005 19:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:477866</guid><dc:creator>shawnfa</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/477866.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=477866</wfw:commentRss><description>Brian Johnson has a new article on MSDN about &lt;A href="http://msdn.microsoft.com/security/?pull=/library/en-us/dnvs05/html/vs05security.asp"&gt;New Security Features in Visual Studio 2005&lt;/A&gt;.&amp;nbsp; Definitely worth a read -- he covers a lot of area, from Application Verifier, to ClickOnce, to PermCalc, right on down to unit testing.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=477866" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>A Closer Look at the Simple Sandboxed AppDomain</title><link>http://blogs.msdn.com/shawnfa/archive/2005/08/09/449563.aspx</link><pubDate>Tue, 09 Aug 2005 22:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:449563</guid><dc:creator>shawnfa</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/449563.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=449563</wfw:commentRss><description>&lt;P&gt;Yesterday we took a look at &lt;a href="http://blogs.msdn.com/shawnfa/archive/2005/08/08/449050.aspx"&gt;Whidbey's new Simple Sandboxing API&lt;/A&gt;.&amp;nbsp; At first glance this API does seem relatively simple, however when you start to look closer at the AppDomain that is created for your sandboxed code, there are a few surprising properties.&lt;/P&gt;
&lt;P&gt;You might expect that under the covers this API is doing the grunt work of creating an AppDomain policy level which grants AllCode the specified permission set, and then has a code group&amp;nbsp;for each strong name specified on the FullTrust list in order to provide those assemblies FullTrust.&amp;nbsp; However, this is not how the API works -- &lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;it actually uses an entirely different security model than the traditional policy level based one&lt;/SPAN&gt;.&amp;nbsp; In fact, there is no AppDomain policy level in the sandboxed domain at all!&amp;nbsp; Instead the sandboxed domain simply keeps track of a set of FullTrust assemblies and a permission set to be granted to all other assemblies and the AppDomain itself.&amp;nbsp; No policy resolution will be done for assemblies loaded into this type of domain.&lt;/P&gt;
&lt;P&gt;Why does Whidbey add this second AppDomain security model?&amp;nbsp; Aside from making it trivial for applications to sandbox untrusted code, it's also required for the ClickOnce security model.&amp;nbsp; ClickOnce allows an application to specify the exact set of permissions it should run under.&amp;nbsp; ClickOnce application authors test their applications with these permissions and expect to have exactly their requested permissions at runtime.&amp;nbsp; This AppDomain security model allows for that to occur.&lt;/P&gt;
&lt;P&gt;Similarly, Visual Studio's debug-in-zone feature also requires an environment where the permissions it requests are exactly the permissions it gets -- if it were to debug your application with fewer privileges, debug-in-zone could lead to a lot of confusion when operations that are expected to pass start throwing SecurityExceptions.&lt;/P&gt;
&lt;P&gt;Finally lets take a look at that evidence parameter to the CreateDomain API.&amp;nbsp; Since a sandboxed AppDomain does not resolve policy and always has a domain permission set equal to the grant set of the assemblies loaded into it, why does it need Evidence?&amp;nbsp; Technically the domain itself doesn't need that parameter, and it won't ever look at it directly.&amp;nbsp; However, the evidence is still stored on the AppDomain's Evidence property.&amp;nbsp; This means that other features which make decisions based upon AppDomain evidence (such as isolated storage), can still work with code executing in a simple sandboxed domain without modification.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=449563" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/ClickOnce/default.aspx">ClickOnce</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Under+the+Hood/default.aspx">Under the Hood</category></item><item><title>Profiling Signed Assemblies</title><link>http://blogs.msdn.com/shawnfa/archive/2005/07/26/443584.aspx</link><pubDate>Wed, 27 Jul 2005 00:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:443584</guid><dc:creator>shawnfa</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/443584.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=443584</wfw:commentRss><description>&lt;a href="http://blogs.msdn.com/ianhu"&gt;Ian Huff&lt;/A&gt; has an entry today about the problems you'll run into when &lt;a href="http://blogs.msdn.com/ianhu/archive/2005/07/25/443021.aspx"&gt;using Visual Studio Team System to profile assemblies that have a strong name signature&lt;/A&gt;.&amp;nbsp; He walks through the steps necessary to cause Visual Studio to resign your assemblies after they have been instrumented by the profiler.&amp;nbsp; It's a good page to bookmark if you plan on using the VSTS performance tools with code that gets signed.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=443584" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/StrongName/default.aspx">StrongName</category></item><item><title>Beta 2, Get Yer Beta 2</title><link>http://blogs.msdn.com/shawnfa/archive/2005/04/18/409304.aspx</link><pubDate>Mon, 18 Apr 2005 20:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:409304</guid><dc:creator>shawnfa</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/409304.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=409304</wfw:commentRss><description>&lt;P&gt;As I'm sure most of you have seen by now, &lt;A href="http://www.microsoft.com/presspass/press/2005/Apr05/04-18VSSQL2005PR.asp"&gt;today we announced the availability&lt;/A&gt; of Visual Studio 2005 Beta 2 and SQL Server 2005 April Community Tech Preview.&amp;nbsp; The release is a huge step over the old beta 1 bits, and &lt;A href="http://lab.msdn.microsoft.com/vs2005/get/"&gt;can be found on MSDN&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;One of the nicer aspects of the beta 2 help system is that it is linked to the &lt;A href="http://forums.microsoft.com/msdn/"&gt;MSDN Forums&lt;/A&gt; site.&amp;nbsp; Forums are sort of a living FAQ, hopefully a nicer extension of the newsgroup model.&amp;nbsp; Currently there's no dedicated security forum, but if any of you feel like we should create one feel free to post a request in the &lt;A href="http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=52"&gt;Ideas &amp;amp; Suggestions Forum&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Over the next several weeks, I'll be posting about the many new security features that have appeared since last year's release; but for now I've got a beta to install ... :-)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=409304" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Finding Out The Current User in the Debugger</title><link>http://blogs.msdn.com/shawnfa/archive/2004/09/23/233665.aspx</link><pubDate>Fri, 24 Sep 2004 01:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:233665</guid><dc:creator>shawnfa</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/233665.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=233665</wfw:commentRss><description>&lt;p&gt;Every once in a while, while debugging multi-threaded applications that do impersonation, it becomes useful to figure out the context that the current thread is running under.&amp;nbsp; This is especially useful when debugging server scenarios where connections are farmed out to worker threads which begin their work by impersonating the user logging in.&amp;nbsp; Before Whidbey finding this information wasn't very straightforward, and even when you found out the current user, it was difficult to find out any other security token information.&lt;/p&gt; &lt;p&gt;Thankfully the VS Whidbey debugger team has stepped up with a nice solution to this problem.&amp;nbsp; You can now evaluate the $user pseudo-register in the debugger, and find out all about the context that the current process and thread are running under.&amp;nbsp; In addition to the user name, this variable also shows their SID, session id, login id, impersonation level, and active privileges.&amp;nbsp; In addition to this, information on all the groups that the active user is a member of is listed.&lt;/p&gt; &lt;p&gt;If the current thread is impersonating, then information on the user the thread is impersonating as is also available.&amp;nbsp; Here's what this might look like on a thread that is not impersonating:&lt;/p&gt; &lt;p&gt;&lt;img alt="Evaluating the $user pseudo-register in the VS Whidbey QuickWatch window" src="http://www.sfarkas.net/images/blog/UserVar.png" /&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=233665" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>Whidbey's New SecurityException</title><link>http://blogs.msdn.com/shawnfa/archive/2004/07/30/202468.aspx</link><pubDate>Fri, 30 Jul 2004 19:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:202468</guid><dc:creator>shawnfa</dc:creator><slash:comments>14</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/202468.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=202468</wfw:commentRss><description>&lt;P&gt;One of the more difficult things to debug with .NET 1.0 and 1.1 is the security exception.&amp;nbsp; With these frameworks generally the only information that you got was the state of the failed permission.&amp;nbsp; Due to the complexity of debugging security problems, most people just gave up and required that their code run in a fully trusted environment.&amp;nbsp; With Whidbey we've done a lot of work to beef up the security exception, and make debugging security issues even easier, in the process making it easier for developers to figure out the minimum set of permissions that their application needs to run under.&lt;/P&gt;
&lt;P&gt;
&lt;H2&gt;Limitations of the Current&amp;nbsp;Implementation&lt;/H2&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Currently, the SecurityException contains four security specific properties.&lt;BR&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritysecurityexceptionclassgrantedsettopic.asp"&gt;GrantedSet&lt;/A&gt;&amp;nbsp;provides the set of permissions that are granted to the assembly that failed.&amp;nbsp; This property does not get filled out every time an exception is thrown however. 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecuritySecurityExceptionClassPermissionStateTopic.asp"&gt;PermissionState&lt;/A&gt; has the permission or permission set that caused the exception to be thrown 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecuritySecurityExceptionClassPermissionTypeTopic.asp"&gt;PermissionType&lt;/A&gt; is also not always filled out, when it is, it should contain if PermissionState is a permission, permission set, or permission set collection 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecuritySecurityExceptionClassRefusedSetTopic.asp"&gt;RefusedSet&lt;/A&gt; contains the set of permissions that were refused by by the assembly that caused the security exception to be thrown&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Generally, PermissionState is the only property that can be depended upon to always have a value.&amp;nbsp; This does not provide for a good user experience.&lt;/P&gt;
&lt;P&gt;
&lt;H2&gt;The Whidbey SecurityException&lt;/H2&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The Whidbey SecurityException adds several more properties, which together allow developers to figure out what code was causing a security problem.&amp;nbsp; The new properties are:&lt;/P&gt;
&lt;TABLE border=2&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;B&gt;Name&lt;/B&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;B&gt;Type&lt;/B&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;B&gt;Description&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Action &lt;/TD&gt;
&lt;TD&gt;SecurityAction&lt;/TD&gt;
&lt;TD&gt;the SecurityAction that failed the security check&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Demanded &lt;/TD&gt;
&lt;TD&gt;object&lt;/TD&gt;
&lt;TD&gt;the permission, permission set, or permission sets that were demanded and triggered the exception&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;DenySetInstance &lt;/TD&gt;
&lt;TD&gt;object&lt;/TD&gt;
&lt;TD&gt;if&amp;nbsp;a Deny&amp;nbsp;stack frame caused the security exception to fail, then this property will contain that set, otherwise it will be null.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;FailedAssemblyInfo &lt;/TD&gt;
&lt;TD&gt;AssemblyName&lt;/TD&gt;
&lt;TD&gt;AssemblyName of the assembly that caused the security check to fail&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;FirstPermissionThatFailed &lt;/TD&gt;
&lt;TD&gt;IPermission&lt;/TD&gt;
&lt;TD&gt;the first permission in failing PermissionSet (or PermissionSetCollection) that did not pass the security check&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Method&lt;/TD&gt;
&lt;TD&gt;MethodInfo&lt;/TD&gt;
&lt;TD&gt;the method that the failed assembly was in when it encountered the security check that triggered the exception.&amp;nbsp; If a PermitOnly or Deny stack frame failed, this will contain the method that put the PermitOnly or Deny frame on the stack.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;PermitOnlySetInstance&lt;/TD&gt;
&lt;TD&gt;object&lt;/TD&gt;
&lt;TD&gt;if the stack frame that caused the security exception had a PermitOnly permission set, this property will contain it, otherwise it will be null&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Url &lt;/TD&gt;
&lt;TD&gt;string&lt;/TD&gt;
&lt;TD&gt;URL of the assembly that failed the security check&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Zone &lt;/TD&gt;
&lt;TD&gt;SecurityZone&lt;/TD&gt;
&lt;TD&gt;Zone of the assembly that failed the security check&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;As you can see, there's a ton more data available about the cause of the security exception in Whidbey.&amp;nbsp; However, as I noted above, even the current SecurityException properties don't get filled out properly all the time.&amp;nbsp; As part of the SecurityException enhancement work, we've gone through all the places in the BCL that throw exceptions and ensured that they've filled out as much of the SecurityException data as possible.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;
&lt;H2&gt;So What Does a New Security Exception Look Like?&lt;/H2&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;All of these extra properties provide a lot of information for developers to work with if they catch the SecurityException in their code.&amp;nbsp; But what happens if the exception goes unhandled?&amp;nbsp; The default behavior of spewing exception information to the screen will still provide a lot more information than was provided before.&amp;nbsp; For instance, if I tried to run my &lt;A href="http://blogs.msdn.com/shawnfa/archive/2004/05/05/126825.aspx"&gt;ProtectedData sample &lt;/A&gt;off a network share, with default policy in place, I'd end up with a SecurityException.&amp;nbsp; The debug spew for that exception would look similar to the following. 
&lt;P&gt;
&lt;P&gt;First comes the standard stack trace and exception type that failed.&lt;BR&gt;
&lt;DIV class=codeblock&gt;Unhandled Exception: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.DataProtectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.&lt;BR&gt;at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken,CodeAccessPermission demand, StackCrawlMark&amp;amp; stackMark, Int32 checkFrames, Int32 unrestrictedOverride)&lt;BR&gt;at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark&amp;amp; stackMark)&lt;BR&gt;at System.Security.CodeAccessPermission.Demand()&lt;BR&gt;at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope)&lt;BR&gt;at CPD.Main() in \\shawnfa-build\c$\blog\ManagedDPAPI\CryptProtectData.cs:line 12&lt;BR&gt;&lt;/DIV&gt;&lt;BR&gt;&lt;BR&gt;This is followed up by the SecurityAction that failed, the first failed permission, and the details of the demanded permissions. (From now on, I'm going to abbreviate the full assembly names.)&lt;BR&gt;
&lt;DIV class=codeblock&gt;The action that failed was:&lt;BR&gt;Demand&lt;BR&gt;The type of the first permission that failed was:&lt;BR&gt;System.Security.Permissions.DataProtectionPermission&lt;BR&gt;The first permission that failed was:&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.DataProtectionPermission, mscorlib ... "&lt;BR&gt;version="1"&lt;BR&gt;Flags="ProtectData"/&amp;gt;&lt;BR&gt;&lt;BR&gt;The demand was for:&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.DataProtectionPermission, mscorlib ..."&lt;BR&gt;version="1"&lt;BR&gt;Flags="ProtectData"/&amp;gt;&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;&lt;BR&gt;&lt;BR&gt;Next is a list of all the permissions granted to the assembly that failed the demand:&lt;BR&gt;
&lt;DIV class=codeblock&gt;The granted set of the failing assembly was:&lt;BR&gt;&amp;lt;PermissionSet class="System.Security.PermissionSet"&lt;BR&gt;version="1"&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib ..."&lt;BR&gt;version="1"&lt;BR&gt;Read="USERNAME"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib ..."&lt;BR&gt;version="1"&lt;BR&gt;Unrestricted="true"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.FileIOPermission, mscorlib ..."&lt;BR&gt;version="1"&lt;BR&gt;Read="\\SHAWNFA-BUILD\C$\blog\ManagedDPAPI\"&lt;BR&gt;PathDiscovery="\\SHAWNFA-BUILD\C$\blog\ManagedDPAPI\"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib ..."&lt;BR&gt;version="1"&lt;BR&gt;Allowed="AssemblyIsolationByUser"&lt;BR&gt;UserQuota="9223372036854775807"&lt;BR&gt;Expiry="9223372036854775807"&lt;BR&gt;Permanent="True"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib ..."&lt;BR&gt;version="1"&lt;BR&gt;Flags="ReflectionEmit"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, ..."&lt;BR&gt;version="1"&lt;BR&gt;Flags="Assertion, Execution, BindingRedirects"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.UIPermission, mscorlib, ..."&lt;BR&gt;version="1"&lt;BR&gt;Unrestricted="true"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, ..."&lt;BR&gt;version="1"&lt;BR&gt;Url="file://shawnfa-build/c$/blog/ManagedDPAPI/CryptProtectData.exe"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, ..."&lt;BR&gt;version="1"&lt;BR&gt;Zone="Intranet"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Net.DnsPermission, System ..."&lt;BR&gt;version="1"&lt;BR&gt;Unrestricted="true"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Windows.Forms.WebBrowserPermission, System ..."&lt;BR&gt;version="1"&lt;BR&gt;Level="Restricted"/&amp;gt;&lt;BR&gt;&amp;lt;IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing ..."&lt;BR&gt;version="1"&lt;BR&gt;Level="DefaultPrinting"/&amp;gt;&lt;BR&gt;&amp;lt;/PermissionSet&amp;gt;&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;&lt;BR&gt;&lt;BR&gt;Finally, the assembly that failed the permission demand is listed along with the method that called into the demanding code, and the Zone and URL evidence for that assembly.&lt;BR&gt;
&lt;DIV class=codeblock&gt;The assembly that failed was:&lt;BR&gt;CryptProtectData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null&lt;BR&gt;The method that caused the failure was:&lt;BR&gt;Void Main()&lt;BR&gt;The Zone of the assembly that failed was:&lt;BR&gt;Intranet&lt;BR&gt;The Url of the assembly that failed was:&lt;BR&gt;file://shawnfa-build/c$/blog/ManagedDPAPI/CryptProtectData.exe&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;
&lt;H2&gt;Visual Studio Gets In On The Action&lt;/H2&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;In addition to all the work done in the CLR to make debugging security exceptions easier, Visual Studio 2005 has done quite a bit of work as well.&amp;nbsp; When an unhandled&amp;nbsp;SecurityException is thrown under the VS debugger, Visual Studio will look at all of the extra properties that are populated on that exception, and provide you with context sensitive help to solve the problem.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=545 alt="Visual Studio 2005 Security Exception Handler" src="http://www.sfarkas.net/images/blog/VSSecurityException.png" width=788 border=2&gt;&lt;/P&gt;
&lt;P&gt;As you can see in the screen shot, VS will highlight the line that caused the SecurityException, and shows a pop up dialog that tells you the permission that failed and provides several possible solutions for the problem.&amp;nbsp; In this case, there's not a lot of ways to get around the DataProtectionPermission demand, so the options that VS presents include turning this into a ClickOnce application or installing locally.&amp;nbsp; This help is based around the failing permission, so if a FileIOPermission failed, VS might suggest using IsolatedStorage instead.&lt;/P&gt;
&lt;P&gt;The View Details link will, oddly enough, open up the View Detail dialog where you can inspect each property of the Security Exception yourself, in order to help you further track down security issues.&lt;/P&gt;
&lt;P&gt;
&lt;H2&gt;Debug-In-Zone&lt;/H2&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;All that's fine and good, but when you develop on your local machine, you end up with FullTrust by default.&amp;nbsp; Forcing developers to modify their security policy to debug is not a good user experience, so again Visual Studio steps up to the plate, this time with a feature called Debug In Zone.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=488 alt="Debug In Zone Settings" src="http://www.sfarkas.net/images/blog/DebugInZone.png" width=591 border=2&gt;&lt;/P&gt;
&lt;P&gt;By going to your project properties, and accessing the security tab, you can specify the set of permissions that you'd like to debug your application with.&amp;nbsp; For instance, if your goal is to have your application run with Internet permissions, then just select Internet from the drop down list.&amp;nbsp; You can also create a custom permission set that reduces down to the exact set of permissions that your app needs;&amp;nbsp;the Calculate Permissions button, which will interface with PermCalc will help you with this goal.&lt;/P&gt;
&lt;P&gt;With the changes to the SecurityException&amp;nbsp;class and enhancements to the Visual Studio debugger, figuring out the cause of those hard to diagnose SecurityExceptions.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=202468" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/ClickOnce/default.aspx">ClickOnce</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>What Happens When My Application Throws An Unhandled Exception</title><link>http://blogs.msdn.com/shawnfa/archive/2004/07/15/184490.aspx</link><pubDate>Thu, 15 Jul 2004 21:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:184490</guid><dc:creator>shawnfa</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/184490.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=184490</wfw:commentRss><description>&lt;P&gt;There are several different behaviors that can occur when a managed application throws an unhandled exception.&amp;nbsp; The two most common are to bring up an error dialog box, or to pop up the Visual Studio Just In Time Debugger dialog box.&lt;/P&gt;
&lt;P&gt;The first behavior is the default when you install the CLR, but don't install Visual Studio.&amp;nbsp; Installing VS modifies the default to pop up the select-a-debugger dialog.&amp;nbsp; How does the CLR figure out what behavior to use?&amp;nbsp; It checks a registry key, located at HKLM\Software\Microsoft\.NetFramework\DbgJITDebugLaunchSetting.&amp;nbsp; The value of this key lets the CLR know what to do when it encounters an unhandled exception.&amp;nbsp; Possible values are:&lt;/P&gt;
&lt;TABLE border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;B&gt;Value&lt;/B&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;B&gt;Action&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;Bring up the unhandled exception dialog box. (Click OK to terminate ...)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;Print out the stack trace of the exception and terminate the application&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;Invoke the default managed debugger&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;If the value is set to 2, then the CLR consults HKLM\Software\Microsoft\.NetFramework\DbgManagedDebugger to determine which debugger to launch.&amp;nbsp; This debugger is expected to be a managed debugger, that uses the CLR debugging interface.&amp;nbsp; The debugger listed in this key will get four parameters, specified using printf style % format characters.&amp;nbsp; The parameters are:&lt;/P&gt;
&lt;TABLE border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Parameter number&lt;/TD&gt;
&lt;TD&gt;Meaning&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;PID of the process&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;ID of the AppDomain&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;Exception string ("System.OutOfMemoryException"), as a wide character string&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;Event handle to signal when aborting the attach operation&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;By default, Visual Studio registers the VSJITDebugger.exe program as the debugger, which is what is responsible for displaying the familiar choose-a-debugger dialog box.&amp;nbsp; The default registration for this debugger in Visual Studio 2003 is:&lt;/P&gt;
&lt;P&gt;
&lt;DIV class=codeblock&gt;"C:\Program Files\Common Files\Microsoft Shared\VS7Debug\VsJITDebugger.exe" PID %d APPDOM %d EXTEXT "%s" EVTHDL %d&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=184490" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Under+the+Hood/default.aspx">Under the Hood</category></item><item><title>ClickOnce Bootstrapper Manifest Generator</title><link>http://blogs.msdn.com/shawnfa/archive/2004/07/07/175700.aspx</link><pubDate>Wed, 07 Jul 2004 20:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:175700</guid><dc:creator>shawnfa</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/175700.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=175700</wfw:commentRss><description>David Guyer, from the VB.Net test team, has released his &lt;A href="http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=ddb4f08c-7d7c-4f44-a009-ea19fc812545"&gt;ClickOnce Bootstrapper Manifest Generator &lt;/A&gt;on &lt;A href="http://www.gotdotnet.com"&gt;GotDotNet&lt;/A&gt;.&amp;nbsp; This tool allows you to generate manifests that describe any pre-requisites to install for a ClickOnce application.&amp;nbsp; You can find more details in the&amp;nbsp;&lt;A href="http://blogs.msdn.com/powertoys/archive/2004/07/07/175648.aspx"&gt;Powertoys blog&lt;/A&gt;.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=175700" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/ClickOnce/default.aspx">ClickOnce</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>New Debugger Features for Whidbey</title><link>http://blogs.msdn.com/shawnfa/archive/2004/07/01/171195.aspx</link><pubDate>Thu, 01 Jul 2004 20:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:171195</guid><dc:creator>shawnfa</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/171195.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=171195</wfw:commentRss><description>&lt;A href="http://blogs.msdn.com/andypennell/archive/2004/06/29/169002.aspx"&gt;Andy blogs &lt;/A&gt;about the new features in the Visual Studio 2005 debugger.&amp;nbsp; Of all these, tracepoints seems the most exciting to me, although life will be made much easier with visualizers and the STL data display.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=171195" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Debugging/default.aspx">Debugging</category></item></channel></rss>