<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Wah On Terra .NET: Martin Granell's Blog</title><link>http://wah.onterra.net/blog/</link><description>Attacking the scary bits in .NET</description><managingEditor>Martin Granell</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Martin Granell</dc:creator><title>Back in the world of blogging, just moved.</title><link>http://wah.onterra.net/blog/archive/2006/05/18/10772.aspx</link><pubDate>Thu, 18 May 2006 14:10:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2006/05/18/10772.aspx</guid><description>&lt;P&gt;&lt;FONT face=Tahoma&gt;New blog home: &lt;/FONT&gt;&lt;A href="http://granell.net/martin"&gt;&lt;FONT face=Tahoma&gt;http://granell.net/martin&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Its been a while, but I now have my blogging fingers primed, after a long absence, having been very busy offline these past few months. I will also be putting up my demos and slides from the various user groups/conferences I've been at during this time, so see you there.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Wah.Onterra is dead, long live Granell.NET&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Yours,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Martin&lt;/FONT&gt;&lt;/P&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/10772.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>#! /usr/bin/vbc  support for windows script (or self-compiling .NET scripts)</title><link>http://wah.onterra.net/blog/archive/2005/08/09/2804.aspx</link><pubDate>Tue, 09 Aug 2005 11:27:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/08/09/2804.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=2804"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;DIV class=Section1&gt;
&lt;P&gt;One of the &amp;#8220;nice&amp;#8221; things about the unix shell is the ability to create a script file that contains the program that will run the script at the top of the file. This allows all kinds of extensibility in the shell, and the ability to plug in your favourite script interpreter. This post shows how to create the same effect for .NET 1.1 on windows.&lt;/P&gt;
&lt;P&gt;I was just reading &lt;A href="http://www.adopenstatic.com/cs/blogs/ken/archive/2005/06/03/25.aspx"&gt;Ken Schaefer&lt;/A&gt;&amp;#8217;s blog about using Windows Scripting Host, and it reminded me of some old code I had written that was a self-compiling VB.NET WSF script. An example script is below:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;' vbc /r:System.Windows.Forms.dll&lt;BR&gt;'&amp;lt;job id="IncludeExample"&amp;gt;&amp;lt;script language="JScript"&amp;gt;var WshShell = WScript.CreateObject("WScript.Shell");var filespec = WshShell.ExpandEnvironmentStrings("%TEMP%")+"\\" +WScript.ScriptName+".exe";var fso=WScript.CreateObject("Scripting.FileSystemObject");if (fso.FileExists(filespec)) fso.DeleteFile(filespec);var ts=fso.OpenTextFile(WScript.ScriptFullName, 1);var comp = ts.ReadLine();comp=comp.substring(comp.indexOf(" ")+1);ts.Close();var f=fso.GetFolder(WshShell.ExpandEnvironmentStrings("%windir%\\Microsoft.NET\\Framework\\"));if (!f) WScript.Echo("You must have the .NET Runtime installed");var netVersion="";fc = new Enumerator(f.SubFolders);for (;!fc.atEnd(); fc.moveNext()){if (fc.item().name &amp;gt; netVersion)netVersion = fc.item().Path;}oExec = WshShell.Exec(netVersion + "\\" + comp + " /out:"+filespec+" /target:exe /debug "+WScript.ScriptFullName);while (oExec.Status == 0){if (!oExec.StdOut.AtEndOfStream){WScript.Echo(oExec.StdOut.ReadAll());}WScript.Sleep(100);};if (!oExec.StdOut.AtEndOfStream){WScript.Echo(oExec.StdOut.ReadAll());}if (!fso.FileExists(filespec)) WScript.Quit(1);oExec = WshShell.Exec(filespec);while (oExec.Status == 0){if (!oExec.StdOut.AtEndOfStream){WScript.Echo(oExec.StdOut.ReadAll());}if (!oExec.StdErr.AtEndOfStream){WScript.Echo(oExec.StdErr.ReadAll());}WScript.Sleep(100);};if (!oExec.StdOut.AtEndOfStream){WScript.Echo(oExec.StdOut.ReadAll());}if (!oExec.StdErr.AtEndOfStream){WScript.Echo(oExec.StdErr.ReadAll());}&amp;lt;/script&amp;gt;&amp;lt;/job&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;' A "Hello World!" program in Visual Basic.&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;Imports System&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;Imports Microsoft.VisualBasic&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;Imports System.Windows.Forms&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;Module Hello&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp; Sub Main()&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Console class from .NET&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.Write("To the console...")&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Intrinsic VB compatible code&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox("Hello World!")&amp;nbsp;&amp;nbsp; ' Display message on computer screen.&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Example of using the shell object&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim shell as Object = CreateObject("WScript.Shell")&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shell.Popup("hello2")&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Example of using a referenced assembly&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("This is using System.Windows.Forms")&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;End Module&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The magic in this script comes from the second line, which contains a valid WSF fragment. It is also VB.NET commented, so that the file is a valid VB.NET file. The code searches for the latest version of the .NET runtime, reads the first line of itself for the compiler and any additional arguments (e.g. references to other assemblies), compiles the .exe into the TEMP directory, and then runs the executable, making sure to copy standard out and error out into the console window.&lt;/P&gt;
&lt;P&gt;To run the example, copy it into a file named foo.wsf, and run:&lt;/P&gt;
&lt;P&gt;cscript foo.wsf&lt;/P&gt;
&lt;P&gt;If you wanted to use the c# compiler instead, it would be a small matter of changing the compiler in the first line, and making the code compatible (of course you couldn&amp;#8217;t use the late binding support available within VB.NET). Now you have the full power of .NET without having to run the compiler manually&amp;#8230;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/2804.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>MVP Award</title><link>http://wah.onterra.net/blog/archive/2005/07/02/1624.aspx</link><pubDate>Sat, 02 Jul 2005 07:27:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/07/02/1624.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=1624"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;div class="Section1"&gt; &lt;p&gt;I would like to thank those who have nominated me, both internally and externally to Microsoft, for my being awarded MVP status. I will endeavor to extend my community involvement over the coming year, with more presentations, break out sessions, technical postings and helping out with some of the trickier questions in the architecture and patterns forums.&lt;/p&gt; &lt;p&gt;The dearth of postings on this blog is crying out to be filled, and I have a whole suite of juicy technical postings to post, that have been building up while I&amp;rsquo;ve been head down buried in curriculum development land. &amp;nbsp;On the cooking platter at the moment are a series of tools and updates to help people building solutions using Enteprise Library, and various code generation pieces.&lt;/p&gt; &lt;p&gt;Btw, if you are in Amsterdam for TechEd Europe, then I might see you there&amp;hellip;&lt;/p&gt;&lt;/div&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/1624.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>Configuration WebCast with Hands On Lab</title><link>http://wah.onterra.net/blog/archive/2005/03/05/320.aspx</link><pubDate>Sat, 05 Mar 2005 20:01:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/03/05/320.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=320"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;div class="Section1"&gt; &lt;p&gt;This morning (US time), &lt;a href="http://blogs.msdn.com/rjacobs/archive/2005/03/04/385710.aspx"&gt;Ron Jacobs&lt;/a&gt; and &lt;a href="http://weblogs.asp.net/scottdensmore"&gt;Scott Densmore&lt;/a&gt; did a web cast on the Configuration Block of Enterprise Library. For the web cast series we are building a set of hands on labs, which step you through how to use the various blocks. You can download the Configuration hands on lab (and future labs) from Ron&amp;rsquo;s &lt;a href="http://www.ronjacobs.com/webcasts.htm"&gt;website&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Please leave feedback on the lab, as we&amp;rsquo;re in the middle of building the labs for the next set of webcasts, and we&amp;rsquo;d love to get your input on how to improve the lab. I&amp;rsquo;d also be interested in what languages people are using with Enterprise Library, is it mainly VB.NET and C#, or have people tried more exotic languages like &lt;a href="http://www.ironpython.com/"&gt;IronPython&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/320.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>Greg Low joins our happy team</title><link>http://wah.onterra.net/blog/archive/2005/02/20/302.aspx</link><pubDate>Sun, 20 Feb 2005 22:58:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/02/20/302.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=302"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;div class="Section1"&gt; &lt;p&gt;Greg Low&amp;nbsp;has &lt;a href="http://msmvps.com/greglow/archive/2005/02/20/36481.aspx"&gt;announced&lt;/a&gt; that he is joining our team. Congratulations Greg, and I look forward to working with you into the future.&lt;/p&gt;&lt;/div&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/302.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>Enterprise Library Demo from tonights user group meeting</title><link>http://wah.onterra.net/blog/archive/2005/02/18/288.aspx</link><pubDate>Fri, 18 Feb 2005 00:27:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/02/18/288.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=288"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;DIV class=Section1&gt;
&lt;P&gt;Hi folks,&lt;/P&gt;
&lt;P&gt;Here&amp;#8217;s the web service that I demoed tonight. This web service provides an authenticated and instrumented web service that uses a persistent, encrypted database cache to support web farm caching of generated results in 60 lines of code. It also (coincidentally) makes use of every one of the Enterprise Library application blocks directly, or through configuration.&lt;/P&gt;
&lt;P&gt;You can download the demo &lt;A href="http://wah.onterra.net/files/SecureGIS.zip"&gt;here&lt;/A&gt;. The powerpoint file&amp;nbsp;can be found at the Enterprise Library gotdotnet&amp;nbsp;&lt;A href="http://workspaces.gotdotnet.com/entlib"&gt;workspace&lt;/A&gt; (under releases on the right-hand side), &lt;A href="http://www.gotdotnet.com/workspaces/releases/checkForDownload.aspx?id=295a464a-6072-4e25-94e2-91be63527327&amp;amp;releaseid=00d295a8-c274-4ef9-9ac9-769a8924f389"&gt;this&lt;/A&gt; is a direct link to that file.&lt;/P&gt;
&lt;P&gt;To run, ensure that you have created the Caching and Security databases (by running the .cmd files in the Enterprise Library source). Add a user &amp;#8220;martin&amp;#8221;, password &amp;#8220;martin&amp;#8221; using the SecurityDatabaseConsole.exe program. Make sure that the ASPNET account has access to the databases. You may also need to run the &amp;#8220;Install Services&amp;#8221; script to register instrumentation sources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/288.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>Declarative security with Enterprise Library (The Real Thing)</title><link>http://wah.onterra.net/blog/archive/2005/02/10/264.aspx</link><pubDate>Thu, 10 Feb 2005 00:42:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/02/10/264.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=264"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;DIV class=Section1&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Lets start off with &lt;I&gt;&lt;SPAN style="FONT-STYLE: italic"&gt;Why bother to use declarative security attributes?&lt;/SPAN&gt;&lt;/I&gt; It&amp;#8217;s only a few more lines of code to write:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&amp;nbsp;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;public &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;void &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=black&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;DoSomethind()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IAuthorizationProvider prov = AuthorizationFactory.GetAuthorizationProvider();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;if&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=black&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;(!prov.Authorize(Thread.CurrentPrincipal, "important stuff"))&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;throw &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;new &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=black&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;SecurityException("Not allowed to do this");&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Versus:&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;[AuthorizationPermission(SecurityAction.Demand,&amp;nbsp; Context = "important stuff")]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;public &lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;void &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=black&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;DoSomethind()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: 'Courier New'"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;But there are two main advantages to the attribute approach (as well as reduced LOC, and cleaner code):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;1.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; The ability to read the metadata. Permview is an example of an application that can read the meta data from an assembly, and spits out the following for the method above:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;Method AuthTest.Class1::DoSomethind() NonCasDemand permission set:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;&amp;lt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=maroon&gt;&lt;SPAN style="COLOR: maroon; FONT-FAMILY: 'Lucida Console'"&gt;PermissionSet &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: red; FONT-FAMILY: 'Lucida Console'"&gt;class&lt;/SPAN&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;="System.Security.PermissionSet"&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=fuchsia&gt;&lt;SPAN style="COLOR: fuchsia; FONT-FAMILY: 'Lucida Console'"&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;&lt;/FONT&gt;&lt;FONT color=red&gt;&lt;SPAN style="COLOR: red; FONT-FAMILY: 'Lucida Console'"&gt;version&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;="1"&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=maroon&gt;&lt;SPAN style="COLOR: maroon"&gt;IPermission&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=red&gt;&lt;SPAN style="COLOR: red"&gt;class&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;="Readify.EnterpriseLibrary.Permissions.AuthorizationPermissionXml, Readify.Entlib.Permissions"&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=fuchsia&gt;&lt;SPAN style="COLOR: fuchsia; FONT-FAMILY: 'Lucida Console'"&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;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=red&gt;&lt;SPAN style="COLOR: red; FONT-FAMILY: 'Lucida Console'"&gt;version&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;="1"&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=fuchsia&gt;&lt;SPAN style="COLOR: fuchsia; FONT-FAMILY: 'Lucida Console'"&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;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=red&gt;&lt;SPAN style="COLOR: red; FONT-FAMILY: 'Lucida Console'"&gt;unrestricted&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;="False"&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=fuchsia&gt;&lt;SPAN style="COLOR: fuchsia; FONT-FAMILY: 'Lucida Console'"&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;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=red&gt;&lt;SPAN style="COLOR: red; FONT-FAMILY: 'Lucida Console'"&gt;context&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;="important stuff"/&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;&lt;/&lt; span&gt;&lt;SPAN style="COLOR: maroon; FONT-FAMILY: 'Lucida Console'"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;/PermissionSet&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Lucida Console'"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Tahoma color=#000000&gt;This then allows us to scan all the assemblies in the application, and build up a manifest of which methods are protected by which authorities.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;2.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; Flexibility &amp;#8211; If we want to add additional logging to our attribute, or change the factory behaviour, we have one level of isolation from the underlying authorization source (in this case enterprise library).&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000&gt;OK, well how do we build one? Have a look at the source from &lt;/FONT&gt;&lt;A href="http://projectdistributor.readify.net/Projects/Project.aspx?projectId=1"&gt;&lt;FONT face=Tahoma color=#0000ff&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Tahoma color=#000000&gt; to see a finished custom non-code access security attribute. See this &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/eugene_bobukh/archive/2004/03/10/87645.aspx"&gt;&lt;FONT face=Tahoma color=#0000ff&gt;post&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Tahoma color=#000000&gt; for an overview of the process.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000&gt;There are a few tricks to know:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;1.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; The attribute must derive from CodeAccessSecurityAttribute, &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;even&lt;/SPAN&gt;&lt;/B&gt; if it is not a CAS attribute. If it just derives from SecurityAttribute, then the C# compiler will ignore it (although the VB.NET one does the right thing&amp;#8230;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;2.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; The ToXml() method must create an element with the name IPermission, and there must be a class attribute with the assembly qualified name.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;3.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; The assembly must be strongly named, otherwise you won&amp;#8217;t get the compiler to emit the permission.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;4.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; The assembly must either be added to the GAC, or to the Visual Studio devenv.exe directory, for the VS.NET compiler to find it (although the command line compiler does not have the same problem).&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;5.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; The attribute &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;must&lt;/SPAN&gt;&lt;/B&gt; have a single constructor which takes a single SecurityAction parameter. Don&amp;#8217;t be tempted to provide multiple parameters to initialize the attribute instead.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;6.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; The debugger is your friend. Debug visual studio by launching it in the program arguments of the project debugging properties, and step through what your permission and attribute is doing.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;7.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; Reflector is critical. When things start going wrong, the error messages are usually totally irrelevant. Look at the implementation of PermissionSet in reflector, and use permview to dump the XML that your attribute created.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo4"&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="mso-list: Ignore"&gt;8.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; Unit tests. Unit tests. Unit tests. Unit tests. Did I mention unit tests?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000&gt;Now, point number 3 was that the assembly had to be strong named. Since we want to call the authorization interface in enterprise library, and the default installation of enterprise library is not strong named, this is a problem.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000&gt;Well&amp;#8230; back to reflection land. I&amp;#8217;ve created three wrapper classes, that on class constructor dynamically load the weakly named enterprise library using an assembly string, using reflection to grab MethodInfo instances for each the types, and then has some public wrapper methods that invoke the method infos.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000&gt;Performance should not be too bad, and should be outweighed by the real authorization costs being performed anyway. From a security perspective (Trojan succeptability), this is no worse than using the IAuthorizationProvider interfaces directly, if the enterprise library assemblies being used are not strongly named.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000&gt;If you do strongly name your enterprise library, then you can rip out the wrappers, and the calls to the wrappers, and replace with direct calls to the enterprise library factory and interfaces.&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/SPAN&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/264.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>Type Validation errors trying to use non-GAC types in the Enterprise Library Configuration Tool</title><link>http://wah.onterra.net/blog/archive/2005/02/10/261.aspx</link><pubDate>Thu, 10 Feb 2005 00:02:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/02/10/261.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=261"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;div class="Section1"&gt; &lt;p&gt;One of the bugs in Enterprise Library v1.0 relates to Type validation. &amp;nbsp;The problem occurs when selecting a type from an assembly which is not in the Global Asssembly Cache, and not in the EntLibConfig.exe directory.&lt;/p&gt; &lt;p&gt;Example steps to reproduce are:&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Create a project with a custom authorization provider (i.e. derive from ConfigurationProvider, and implement IAuthorizationProvider).&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Add an application configuration file.&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Build the app.&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Run enterprise library, and open the application configuration file.&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Add a Security Application Block section.&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Add a Custom Authorization Provider.&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Click the ellipsis on the type name.&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Add the application assembly containing the custom provider type&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Select the new type.&lt;/p&gt; &lt;p class="MsoListBullet"&gt;&lt;![if !supportLists]&gt;&lt;span style=';font-family:Symbol'&gt;&lt;span style='mso-list:Ignore'&gt;&amp;middot;&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;![endif]&gt;Attempt to save.&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;At this point you will receive a validation error stating that the type is not valid. The problem is that some of the configuration settings have the [TypeValidation] attribute, which will attempt to check that the assembly qualified name of the type is a valid type. Unfortunately, this is running in an App Domain which is rooted in the EntLibConfig.exe directory, and so will only be able to resolves types in assemblies in that directory, or in the GAC.&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;The longer term solution is for the TypeValidation attribute to be able to look in the correct assembly locations, but at the moment you will need to change the enterprise library source.&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;Open the file: &amp;lt;Program Files&amp;gt;\Microsoft Enterprise Library\src\Configuration\Design\Validation\TypeValidationAttribute.cs&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;And comment out line 60:&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&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; // errors.Add(instance, name, SR.ExceptionTypeNotValid(typeName));&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:0cm;text-indent:0cm;mso-list:none'&gt;Re-build Enterprise library by running the batch file:&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:36.0pt;text-indent:0cm;mso-list:none'&gt;&amp;lt;Program Files&amp;gt;\Microsoft Enterprise Library\src\BuildLibrary.bat&lt;/p&gt; &lt;p class="MsoListBullet" style='margin-left:36.0pt;text-indent:0cm;mso-list:none'&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/261.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>New release of String Resource Generator with multi-language SR.strings support</title><link>http://wah.onterra.net/blog/archive/2005/02/09/258.aspx</link><pubDate>Wed, 09 Feb 2005 22:33:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/02/09/258.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=258"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;DIV class=Section1&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE:&lt;/STRONG&gt; There was a problem in the previous release. Method (b) would not work (thanks to VS.NET for not handling satellite assemblies correctly..). I've updated the instructions below, and the sample in the release, to cover what needs to be done to make it work:&lt;/P&gt;
&lt;P&gt;Hi Folks,&lt;/P&gt;
&lt;P&gt;The next release (&lt;STRIKE&gt;1.2.2&lt;/STRIKE&gt; 1.2.3) of the string resource tool is &lt;A href="http://projectdistributor.readify.net/Projects/Project.aspx?projectId=2"&gt;here&lt;/A&gt;&amp;#8230; Changes for this release are:&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-list: Ignore"&gt;1.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;      &lt;/SPAN&gt;&lt;/SPAN&gt; More complete sample, that should cover all of the functionality of the Custom tool and Batch .exe&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-list: Ignore"&gt;2.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;      &lt;/SPAN&gt;&lt;/SPAN&gt; Accessibilty option now works (with VB.NET &amp; C# only at this point, otherwise it can only be public, blame CodeDom).&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-list: Ignore"&gt;3.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;      &lt;/SPAN&gt;&lt;/SPAN&gt; The Resource class generation can be turned off by using &amp;#8220;generate_class = false&amp;#8221;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-list: Ignore"&gt;4.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;      &lt;/SPAN&gt;&lt;/SPAN&gt; SR.strings files can now contain multi-line resources, by doing the following:&lt;/P&gt;
&lt;P&gt;[strings]&lt;BR&gt;ResName(int age) = First Line&lt;BR&gt;= Second Line {0}&lt;BR&gt;= Third Line&lt;BR&gt;NextRes = Blah&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-list: Ignore"&gt;5.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;      &lt;/SPAN&gt;&lt;/SPAN&gt; From release 1.2.1 onwards its possible to use 3 methods of having multiple locales resources in the same project.&lt;BR&gt;(a) Have a primary .resx file (e.g. SR.resx), with the CustomTool option set. Have secondary .resx files (e.g. SR.de.resx, SR.en.us.resx), which do not have a custom tool set.&lt;BR&gt;&lt;BR&gt;b) Have a primary SR.strings file, with one [strings] section with all the neutral resources, with the CustomTool set. Have secondary .strings files (e.g. SR.strings-de) _with_ the Custom Tool set, but with &amp;#8220;#! generate_class = false&amp;#8221; at the beginning of all the secondary .strings files, and locale dependent [strings] sections, e.g:&lt;BR&gt;&lt;BR&gt;SR.strings:&lt;BR&gt;[strings]&lt;BR&gt;ResName = blah&lt;BR&gt;&lt;BR&gt;SR.strings-de:&lt;BR&gt;#! generate_class = false&lt;BR&gt;[strings.de]&lt;BR&gt;ResName = German blah&lt;BR&gt;&lt;BR&gt;SR.strings-de-DE:&lt;BR&gt;#! generate_class = false&lt;BR&gt;[strings.de-DE]&lt;BR&gt;ResName = German in Germany blah&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2"&gt;&lt;STRONG&gt;Note: &lt;/STRONG&gt;The extension on the secondary strings files can be anything, but the base filename must be the non-localized resource name. i.e. SR.de.strings &lt;STRONG&gt;is not valid &lt;/STRONG&gt;because the base name is &amp;#8220;SR.de&amp;#8220;. SR.strings-de is valid, because the base name is &amp;#8220;SR&amp;#8220;. &lt;BR&gt;&lt;BR&gt;c) Multi-locale .strings file. Have a SR.strings file with multiple [strings] sections, one for each locale. e.g.&lt;BR&gt;[strings]&lt;BR&gt;Res1 = Text&lt;BR&gt;...&lt;BR&gt;&lt;BR&gt;[strings.de]&lt;BR&gt;Res1 = German Override&lt;BR&gt;...&lt;BR&gt;&lt;BR&gt;[strings.de.DE]&lt;BR&gt;Res1 = Germany override&lt;BR&gt;...&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;Note that you can combine all of these options if you wish. E.g. a primary SR.strings file with:&lt;BR&gt;[strings]&lt;BR&gt;[strings.en]&lt;BR&gt;[strings.en.US]&lt;BR&gt;&lt;BR&gt;And a secondary SR.strings-de file with:&lt;BR&gt;#! generate_class = false&lt;BR&gt;[strings.de-DE]&lt;BR&gt;[strings.de-CZ]&lt;BR&gt;&lt;BR&gt;which will generate:&lt;BR&gt;SR.de-DE.resx&lt;BR&gt;SR.de-CZ.resx&lt;BR&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/258.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Martin Granell</dc:creator><title>Declarative security with Enterprise Library</title><link>http://wah.onterra.net/blog/archive/2005/02/03/244.aspx</link><pubDate>Thu, 03 Feb 2005 23:35:00 GMT</pubDate><guid>http://wah.onterra.net/blog/archive/2005/02/03/244.aspx</guid><description>&lt;H2&gt;This post and comments can now be found on my new blog &lt;A HREF="http://granell.net/martin/Posts/Post.aspx?postId=244"&gt;here&lt;/A&gt;&lt;/H2&gt;&lt;DIV class=Section1&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;: ok, so it's tomorrow, and I haven't done the post... however I have uploaded the files. You can get the source &lt;A href="http://projectdistributor.readify.net/Releases/Release.aspx?releaseId=6"&gt;here&lt;/A&gt;. Tomorrow, I promise, I'll put up a post describing how I built the code, what issues there were, and how to use it.&lt;/P&gt;
&lt;P&gt;Tomorrow I&amp;#8217;ll be posting some code I&amp;#8217;ve been working on that allow the use of declarative attributes to secure blocks of code, and uses Enterprise Library&amp;#8217;s authorization model to do so. An example line in VB.NET would be:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 9pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT color=#000000&gt;&amp;lt; AuthorizationPermission(SecurityAction.Demand, Context:="OrderBooks" &amp;gt; _&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; OrderBooks()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;!--EndFragment--&gt;
&lt;P&gt;&lt;!--EndFragment--&gt;This is somewhat equivalent to the PrincipalPermission attribute, but uses (in this case the default) IAuthorizationProvider instance obtained through the enterprise library provider model.&lt;/P&gt;
&lt;P&gt;The code will show a few things:&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-list: Ignore"&gt;1)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; How to use the authorization API of enterprise library&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-list: Ignore"&gt;2)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; How to build custom security attributes&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-list: Ignore"&gt;3)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; How to get around the problem of security attributes having to be strong named, but the default install of enterprise library does not use strong naming. (Remember that a strongly named assembly&amp;nbsp;may only reference other strongly named assemblies).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This can be used as part of a defence in depth strategy, typically to secure business methods. One of the great advantages to using security attributes is the ability to use permview to dump which methods in which assemblies require which authorities. This allows a high degree of security visibility and checking.&lt;/P&gt;&lt;/DIV&gt;&lt;img src ="http://wah.onterra.net/blog/aggbug/244.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>