Blog Stats
  • Posts - 94
  • Articles - 0
  • Comments - 10
  • Trackbacks - 0

 

June 2008 Entries

Log the Output from your MSBuild Tasks

In an automated build process, you always need logs as reference for troubleshooting because the task is scheduled and running under the context of a different user, so you won't be able to see console output. If you use MSBuild to run your build tasks, here is how to get it to write to a text file when it runs: msbuild mybuildroutines.msbuild /p:Desitination=WebServer /t:DeployAndTestWebServerBuild /l:FileLogger,Microsoft.Build.Engine;logfile=c:\temp\DeployAndTestWebServerBuild.log Thanks to Miles for discovering this incredibly useful feature.

How much time does a method take to run?

I frequently run into the situation where I quickly want to learn how fast one method or section of code runs in my unit testing.  Here's a quick and dirty way to get it done: long startTime = DateTime.Now.Ticks; ExecuteMyMethod(); long endTime = DateTime.Now.Ticks; TimeSpan timeTaken = new TimeSpan(endTime - startTime); Console.WriteLine("execution time: " + timeTaken.ToString());

WCF: System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL

If you are getting the "Your process does not have access rights to this namespace" error after switching your WCF service to run under a different account, try the following: 1) Install the Windows support tools from your Windows 2003 Server install CD from SUPPORT/TOOLS. 2) Open a command prompt and go to C:\Program Files\Support Tools 3) Run the following: httpcfg set urlacl -u http://+:<PORT>/<SERVICE URL>/ -a "D:(a;;GX;;;<SID>)" after replacing <PORT>, <SERVICE URL>, and <SID> with the appropriate values.  If your service URL is just the default at that port, leave it off, but keep the trailing /.  <SID> of course is the SID...

Add your WebControls to your Web.Config to Simplify References

Ever get sick of repeating the same user control registrations at the top of your user controls, pages, and master pages within your web application?  If so, you might want to try the following to save your self from all that typing. Add this to your web.config (of course modifying it for your controls and control namespaces): <pages>     <controls>         <add tagPrefix="mylib" namespace="My.Web.Components" assembly="My.Web"/>     </controls> </pages> And of course you can have multiple entries in the list.

Dynamically Instantiate Objects from Another Assembly within the Current AppDomain

Reflection is one of the coolest features in .Net.  But to support instantiation of objects from different assemblies within your application domain requires a little finagling: // try this assembly first; full className e.g. MyNameSpace.Pattern.MyClass Type typeToCreate = Type.GetType(className); if (typeToCreate == null) // try the others in the same domain {     Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();     foreach (Assembly assembly in assemblies)     {         if (assembly.FullName.StartsWith("MyNamespace.Pattern")) // only my site dlls         {             typeToCreate = assembly.GetType(className, false);             if (typeToCreate!= null) { break; } // escape the loop because you have your type         }     } } if (typeToCreate!= null) {     Activator.CreateInstance(typeToCreate);     // do...

June 2008 Issue of TechNet Magazine: IT Toolbox

The June 2008 issue of TechNet Magazine is out on the website. Check out my IT Toolbox column here: http://technet.microsoft.com/magazine/0cb20dc7-86de-4680-ba09-cfc6f0b33c3c In this issue I covered: NetSupport Notify Make announcements over the network NetOptics: Teeny Tap Monitor your network DTweak Pro Optimize your computer Microsoft Exchange Server 2007 Administrator's Companion  (book review)

 

 

Copyright © Greg Steen