Welcome to MSDN Blogs Sign in | Join | Help

My latest MSDN Article is the March Edition of MSDN Magazine:

Agile Development: Extend Team Foundation Server To Enable Continuous Integration

The article outlines Extreme Programming (XP) and how continuous integration fits into it and other Agile development methodologies.  It goes onto to describe how to extend Team Foundation Server to use continuous integration.

The code samples for the article were written for Team Foundation Server Beta 3.  There were some changes in the RC version that caused my sample to break.  I will make an update to the code and post it here shortly. 

I received the following question today regarding NTFS Alternate Data Streams and it is a good topic to post:

I just found your NTFS ADS article and class (thanks!) on GotDotNet, yesterday - after seeing most everything else on ADS over the past month.  [Summary: User has been using ADS streams to store metadata and had large binary data in the main stream].  I've been basing much of what I need to do on Indexing Service, but (as far as I can discern) there's no way to get IS to index the ADSs. Is that right?  Also, I think that it is necessary to write some sort of "ADS archiving" utility, since ?only the NTFS file system retains those streams. Is that so? I thought I saw that one CD-R format also could preserve the hidden streams.

I have used this ADS to latch data to files for a long time and works great if the file is always on an NTFS file system.  You lose the streams if you email it or transport the file off to file systems formats that do not supports streams (like ISO 9660, etc).  You can write code to serialize the information in the streams, but once you reach that point is usually means you should pick another way to tie data together.  Most commercial-grade backup software supports saving the NTFS ADS streams.  I haven't seen any CD formats that support this but I really haven't look long and hard for one.  Perhaps, someone reading this can chime in. 

Indexing Service does not support ADS Streams (that I know of), but you could write an IFilter that opens up the streams and indexes the data in the streams.  I haven't seen an IFilter that does this, but it is a interesting idea and very possible.

These are great questions...Thanks!

 

Just another thank you to Josh for his post on how to create update the style for blogs hosted with .Text.  I have updated my style using his tips and thank him for saving us all a ton of time. 

The February Issue of MSDN Magazine is out and an article the I wrote about writing Managed Smart Tags for Office applications is in that issue.  When I began to write the article, I asked a bunch of developers if they had ever written a Smart Tag (managed or unmanaged).  It was 1 out of about 10 actually had written one.  The great thing about Smart Tags is that every company big or small that uses Office can use them in some way.  This can range from a simple link to shipping information based on a unique code or something more complex like aggregating sales information and presenting it in the Research Pane.  I hope the article allows some developers to revisit Smart Tags and do some great thing with them.

If you are willing to share some ideas that you have or have implemented, I think many people would like to hear it.

Here is a link to the article: Realize the Potential of Office 2003 by Creating Smart Tags in Managed Code.  Also, John Durant wrote a great article on Custom Research Services in the same issue that shows how to write a service for the Research Pane. 

There is a good discussion going on about ASP.NET 2.0 Master Templates and the types of templates to include in Whidbey.  My personal opinion is the more types of templates the better because it gives developer's good starting points to creating their own Master Template.  To add your own feedback, go to Brian Goldfarb's Blog.

Remember all the include files you needed to add to do similar templating in ASP?  Wow, that was sure fun.

I got my copy of MSDN out and decided to install Small Business Server 2003.  I have to say that it is probably one of the most complete solutions that we (Microsoft) have ever put together.  After a 30 minute install, I had a fictitious company intranet, extranet, and accounts created with an Exchange Server. I had a registered DNS name and got everything hooked up in minutes where I can remote into my intranet, check email and all the other types of tasks that I routinely do when I remotely hook up to Microsoft's network.  I even can even check this email from my Smartphone which is very, very cool. 

I have to admit that when someone says DNS and Exchange in the same sentence, I tend to pawn those questions off to some on my infrastructure guru friends, but this installation was as straightforward as they come.

I tried to put myself in the shoes of a small business owner that does not have any IT training.  I believe that a small business owner could get this up and running by themselves or with minimal help.  A true testament to the work that the Small Business Team did to really hit the mark. 

A while back I was looking for an API to determine content types.  One API that I found useful was the FindMimeFromData API.  You cane give this method the first 256 bytes of a file and then determine its MIME types (eg. text/plain, text/html, binary content, etc).  It is useful for checking files that might not have an extention or when you want to double check to ensure that the extension fits the MIME type.  Once you determine that you can find other APIs to precisely determine what the file is.  For binary files, this usually means checking the magic number in the file header.

Not sure if this is useful to anyone but thought I'd share the P/Invoke to make it happen (below). 

/// <summary>

/// Utility class contains static method checkType to determine Mime Type

/// </summary>

public class MimeTypeUtil {

             

  [DllImport(@"urlmon.dll", CharSet=CharSet.Auto)]

  private extern static System.UInt32 FindMimeFromData(

       System.UInt32 pBC,

       [MarshalAs(UnmanagedType.LPStr)] System.String pwzUrl,

       [MarshalAs(UnmanagedType.LPArray)] byte[] pBuffer,

       System.UInt32 cbSize,

       [MarshalAs(UnmanagedType.LPStr)] System.String pwzMimeProposed,

       System.UInt32 dwMimeFlags,

       out System.UInt32 ppwzMimeOut,

       System.UInt32 dwReserved);

             

  public static string CheckType(string filePath) {

    byte[] buffer = new byte[256];

    // grab the first 256 bytes on the file

    using (FileStream fileStream = new FileStream(filePath, FileMode.Open)) {

       if (fileStream.Length >=256)

         fileStream.Read(buffer,0,256);

       else

          fileStream.Read(buffer,0,(int)fileStream.Length);

    }

    try {

       System.UInt32 mimeType;

       System.UInt32 returnValue = FindMimeFromData( 0, null, buffer, 256, null, 0, out mimeType, 0);

       System.IntPtr mimeTypePointer = new IntPtr(mimeType);

       return Marshal.PtrToStringUni(mimeTypePointer);

    }

    catch(Exception ex) {

       return ex.Message;

    }

  }   

}

 

There is quite a bit of information posted on developing COM Callable Wrappers in .NET.  Below is some information that I've compiled after developing quite a few.

 Developing COM Callable Wrappers, all types exposed to COM should follow the guidelines presented in the following checklist:

 

-          Ensure AssembyVersionAttribute is set to a static value (i.e. 1.0.0.0 not 1.0.0.*)

-          Add System.Runtime.InteropServices namespace to files that have types exposed to COM.

o        This includes all of the Attributes necessary to create types exposed to COM.

-          An interface defined that exposes properties and methods for the type.

o        Creating this interface manually forces the developer to know that the interface has changed and can plan accordingly.  The alternative is to let the Type Library exporter automatically generate a interface for the type which can lead to accidentally deploying a type with a breaking change.

-          Creating a type (coclass) that implements the interface.

-          Decorate types with ClassInterfaceAttribute with a ClassInterfaceType.None value (i.e. [ClassInterface(ClassInterfaceType.None)] )

o        This attribute controls whether the Type Library Exporter (Tlbexp.exe) automatically generates a class interface for the attributed class.  Since the interface is defined manually and the coclass implements the interface, we are telling the Type Library Exporter that we have done the work ourselves. 

-          Decorate types and interfaces with ComVisibleAttribute with a true value (i.e. [ComVisible(true)] )

o        By default, all ComVisible is set to true.  Explicity setting these options signals which types and members are visible.

-          Decorate all structures, delegates, enumerations, fields, methods, and properties exposed to COM with ComVisibleAttribute with a true value; likewise, set all that are not visible to COM to false.

-          A parameter-less default constructor.

o        Needed to instantiate object via COM.  Parameterized constructors can be declared but cannot be used from COM.

 

The example class below shows a class that follows the guidance outlines in the above checklist.

 

using System;

using System.Reflection;

using System.Runtime.InteropServices;

 

[assembly: AssemblyVersion("1.0.0.0")]

 

namespace ComSample

{

      

 

       [ComVisible(true)]

       interface ICircle

       {

              double Radius {get; set;}

              double ComputeCircumference();

       }

 

  [ClassInterface(ClassInterfaceType.None),

       ComVisible(true)]

       public class Circle : ICircle

       {

              private double radius;

 

              public Circle()

              {

                     // parameterless constructor

              }

 

              [ComVisible(true)]

              public double Radius

              {

                     get{ return radius; }

                     set{ radius = value; }

              }

 

              [ComVisible(true)]

              public double ComputeCircumference()

              {

                           return radius * System.Math.PI;

              }

 

              [ComVisible(false)]

              public double WhatisPi()

              {

                           return System.Math.PI;

              }

       }

}

 

Figure 1. Sample class to be exposed via a CCW.

 

 

Each time the type is to be deployed, the .NET version must be increased.  Following versioning guidelines, each time the CCW is to be deployed, the major or minor version number should be increased.  This also allows the version to be clearly differentiated when the type is viewed.  Updating the version will produce a new CLSID (guid) associated with this type.  This is important step when deploying updated COM Callable Wrappers.

 

Any comments or reccomendations are welcome.

 

I have gotten quite a bit of questions from people that are starting to plan migrations to Virtual Server.  Most people are looking to take existing testing environments or production systems into virtual machines.  Some others are have existing virtual machines that they want to migrate to Virtual Server.  Help is on the way with the Virtual Server Migration Toolkit (VSMT) which is currently avaialable in Beta.  VSMT uses Automated Deployment Services to create virtual machines images of existing systems.  I've used it several times to take images of some dev boxes that I've consolidated....work really well.

VSMT FAQ: http://www.microsoft.com/windowsserversystem/virtualserver/evaluation/vsmtfaq.mspx

Beta Info: http://www.microsoft.com/windowsserversystem/virtualserver/evaluation/vsmtbeta.mspx

 

I've working alot over the past few months on Virtual Server 2005.  One of the great uses of Virtual Server is the ability to quickly stand up a development and test enviroment.  To facilitate that, I created an application called Rapid Test that automates provisioning and mangement of virtual machines as well as automating software delivery. 

This month's MSDN Magazine has an article that details using the Virtual Server API to contruct the Rapid Test application.  The name of the article is Virtual Server 2005 - Program Customized Testing Environments Without Trashing Your Machine”.  It details the design and development of the application and has the full source code.  It should serve as a good reference implementation for doing similar things in Virtual Server 2005.

Please let me know what you think or have ideas on how to make it better.  I promise to post revisions going forward.

 I just wanted to link to a couple of the other active bloggers within MCS Federal:

Stephen Cohen – posts about Enterprise Architecture.  He the one that reminds us that the line of business we help our customers create must be part of the grandiose plan that is Enterprise Architecture.

Aaron Margosis – new bloggers that posts his thoughts and recommendations on security as demonstrated by his first posts on “Not Running as Admin.”

I have heard and read the following statement quite a bit lately: “If a malicious app or hacker has already obtained access to the file system (or some other entity) then you have bigger problems to worry about.”  What this reallys says is that you don't need to protect against some attack vector because you assume there are so many other areas that a malicious app could exploit.  I am guilty of saying and thinking this in the past, but it is past time to stop thinking this way.

I know I've said this in past because it is easy to say and trying to model threats for a hacker that has elevated privileges or a malicious insider is very difficult.  However, modeling this type of threat is critical and there are protections that can be put in place.  Take for example, a hacker that has access to the manipulate the file system.  Using EFS and protecting the key reduces the risk that an attacker can exploit key data.  Sometimes, the risk and impact is not great enough to take those types of measures, but at least you thought about and made a conscious decision to accept that risk.  That is way, way better then just throwing up your hands and saying “If that happens then you have bigger problems to worry about.”     

I just don't think in regular expressions like some people.  I don't use regular expressions often, but every time I need them I wish that I would just learn the syntax because I end up going through a ton of time in debug more trying out various expressions.  Since I haven't bitten the bullet and become a Regex guru, EricGu's Regular Expression Workbench (V2.00)  is the next best thing.  It saved me probably an hour last night with a complex expression.

I've been using Virtual PC to create a common development environment to take with me when I travel.  It is nice to have VS.NET set up in a VM with macros and preferences customized to me.  I also have editors and (licensed) third-party components installed so I always have them. I take a copy of it with me at customer sites and it I don't have to spend time setting up.   The way it configured now is that all my office apps are on the host machine and then I have a “pure” development environment inside the VM.

The issue I’m grappling with is how to keep everything in sync.  For example, if I go on the road and make modification to code, documents, etc.; how do I update everything back on my workstation at home?  I have to update any documents on the host plus any changes in the VM. 

My thought here is to keep nothing on the VM and all files including Visual Studio projects on the host.  When I build a project, the build output would go inside the VM to avoid executing over networked drive. (I do notice a slowdown in VS.NET when opening projects over a shared drive to the host.)  I can then use something like Intellimirror to copy the updates to other machines. 

I'm looking for any suggestions on this.  I'm willing to make a time investment because a good solution will safe a ton of time in the long run.  Anyone have a good solution for this?

 

I have always found NTFS Alternate Data Streams interesting.  It is an easy way to hide metadata from users.   I wrote a utility called ADSFile as a .NET Wrapper for the Win32 API calls.

Someone asked for me to provide the ability to enumerate data streams into ADSFile.  It 's not as straightforward as I thought because the only way I found is to use the BackupRead and BackupSeek APIs to read and find the stream headers.  Code is here: gotdotnet.

 

More Posts Next page »
 
Page view tracker