mike-obrien.net Resume Blog Labs
Thursday, June 07, 2007

If you have worked much with WSS and the many XML definition files that accompany it you will no doubt be generating a lot of guids. The "Tools|Create GUID" can be a bit cumbersome so I searched for an alternative and couldn't find one. So I wrote a simple GUID insert AddIn that adds three links to your editor context menu to insert guids in different formats. First a standard guid; "6D7C589A-DDBB-4B01-BCEE-6F921885F942", second an undecorated guid; "AFCE87A3021C4BF7A51078DFA1F73995" (Good for content type ID's), and third a "registry" guid; "{0E0057DF-B8EC-44E3-A9AA-3EDBFEA7025B}". The setup installs the source as well if you want to modify it.

Visual Studio 2005

Installer: InstallInsertGUIDAddin.EXE (288.28 KB)

Visual Studio 2008

Installer: InstallInsertGUIDAddin2008.EXE (234.92 KB)
Source: InsertGUIDAddinSource2008.zip (101.51 KB)

Thursday, June 07, 2007 5:10:08 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

I cant seem to find an explicit reference in the WSS SDK (Or on "the Google" for that matter) to the FieldRef element in a content type that says the FieldRef ID is the guid of a predefined site column. SO, I'm assuming that is what it is. In reading Inside Microsoft Windows SharePoint Services 3.0 (Excellent book for SharePoint development btw) I don't see this specifically mentioned in the text either but it is implied in the code samples. Lets say we have a site column defined and a content type that makes use of it:

  <Field

      ID="{BED99611-EDE0-41cb-8C05-0FBD96A15D0F}"

      Type="Note"

      RichText="TRUE"

      AppendOnly="TRUE"

      Name="ActivityNotes"

      DisplayName="Activity Notes"

      Sortable="FALSE"

      SourceID="http://schemas.microsoft.com/sharepoint/v3"

      Group="Litware Columns">

  </Field>

 

  <ContentType

      ID="0x0100E71A2716C18B4e96A9B0461156806FFA"

      Name="Company"

      Description="Create a new company"

      Version="0"           

      Group="Litware Content Types" >

 

    <FieldRefs>   

      <FieldRef

         ID="{BED99611-EDE0-41cb-8C05-0FBD96A15D0F}"

         Name="ActivityNotes"

         DisplayName="Activity Notes" />           

    </FieldRefs>

  </ContentType>

So the FieldRef ID is simply a reference to the predefined Field ID in this case. But what if you want to define a field within the content type (Not referencing a predefined field)? Will the guid now become the id for the new custom field? Or do we not define a guid in that case? I wish the SDK gave some more insight. Or if it does I wish I could find it! :)

Thursday, June 07, 2007 4:55:47 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

So I thought I'd give Windows Live Writer a try. Not to shabby! I love the real time spell checking. When using it to connect to dasBlog, make sure you have the "Blogger/MovableType API" enabled in your dasBlog "Services Settings" section.

 

When setting up your account in Live Writer, select the "Another weblog service" weblog type when prompted. Then, when prompted for the provider, select "dasBlog" and set the "Remote posting URL ..." to be "http://www.mysite.com/blog/blogger.aspx". That's all there is to it.

Thursday, June 07, 2007 3:33:56 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Wednesday, June 06, 2007

Having just built a couple of VS2005 addins I wanted to share a couple of resources that really helped me:

Creating Menu Bitmaps and AboutIcons for Add-ins in Visual Studio .NET 2005
Creating a CommandBar and adding Commands to it in a VS.NET Add-in
Visual Studio 2005 Automation Samples

Hopefully when I get more time I can post a walk through. Many thanks to Rick Strahl who seems to always have good info on how to do advanced development in .NET! 9 times out of 10 I'll find something on his blog/site, great resource!

Wednesday, June 06, 2007 7:07:19 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Thursday, May 31, 2007

A while ago I posted a link to MIT's Open Courseware (OCW) site. Recently I have begun to make use of it and wanted to share some of what I have found. First of all, it rocks! It really is a great resource, especially for those who want to learn about a subject and would like to do self study. I didn’t realize this earlier but a number of the courses also publish videos of the lectures. For example 3.091, "Introduction to Solid State Chemistry" has all 35 lectures posted, thats almost 30 hours of lecture time! These videos (If available) can be found possibly in 3 locations, so keep that in mind. The first is on the OCW site. Browse to the course you are interested in, for example Introduction to Solid State Chemistry. Under the "Lecture Notes" (This label may be a little different between courses) section you will find the video streams and the lecture notes. The second location is on the regular class page. 3.091 has a tab called "Videos" and another called "Archives", both have links to lecture videos and notes. Now the third place you can check, if you want to easily download the videos, is Google Video. Searching for "3.091" brings up all but 2 of the course videos which can be downloaded in in a format that can be played by your video IPod. Actually Google Video has over 450 MIT Lectures available for download! There are also nearly 300 UC Berkeley lectures as well. If you want to download any of the lecture videos (to your hard disk) that are offered as a stream on the MIT website you can use a program like FlashGet to save the stream as a file and then convert the file to what you want. The MIT site publishes RealVideo streams (That use the RTSP protocol).

Other courses that offer video lectures are (To name a few):

Physics - Electricity and Magnetism
Physics - Vibrations and Waves
Physics - Classical Mechanics
Physics - General Relativity
Mathematics - Differential Equations
Mathematics - Linear Algebra
Chemistry - Principles of Chemical Science
Chemistry - Solid Sate Chemistry
Biology - Introductory Biology
Computer System Engineering
Circuits and Electronics
Atomistic Computer Modeling of Materials
Media, Education, and the Marketplace
Electromagnetics and Applications

You may want to look on the course listing to see if there is a newer version of the course as newer ones are periodically added.

The OCW site also offers the course syllabus, study materials, readings, exams and a number of other resources. They offer the option to download the entire course as a zip file so that you don’t have to download the resources individually.

Now a few words about the "Introduction to Solid State Chemistry" (3.091) course... If you are interested in learning about chemistry I would highly recommend the 3.091 course. Donald Sadoway is the lecturer for this course and he does an amazing job! You can tell he loves the subject and he knows it very well. He has a great sense of humor and he really makes the material come alive (At least for me anyways). This course lays an excellent foundation for other areas of study.

Thursday, May 31, 2007 3:48:07 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [2]  | 
Thursday, April 12, 2007

So I am trying to write log information to an XML document using the XmlTextWriter.  When it reaches a certian size I want it closed out and archived. What I mean by "closed out" is that while the log file is "open" the root element is not closed so that I can keep adding entries over a period of time. In other words:

<?xml version="1.0"?>
<log>
    <entry date="1/1/2007">Yada yada yada</entry>
    <entry date="1/1/2007">Yada yada yada</entry>
    ...


Then once its full I will write the closing root element and rename it:

<?xml version="1.0"?>
<log>
    <entry date="1/1/2007">Yada yada yada</entry>
    <entry date="1/1/2007">Yada yada yada</entry>
    ...
    <entry date="1/1/2007">Yada yada yada</entry>
</log>

Well the XmlTextWriter automatically closes out all open elements when you close it. Looking in Reflector reveals what is happening behind the scenes:

public override void Close()
{
   try
   {
      this.AutoCompleteAll();
   }
   catch {}
   finally
   {
      this.currentState = State.Closed;
      this.textWriter.Close();
   }
}

First the AutoCompleteAll() method is called, then the underlying stream is closed. The AutoCompleteAll() method is as follows:

private void AutoCompleteAll()
{
   if (this.flush)
   {
      this.FlushEncoders();
   }
   while (this.top > 0)
   {
      this.WriteEndElement();
   }
}

Doesent look like there is any official way to explicitly close only the elements you want to close, its just automatically done for you when you close the writer. The only work around I could figure out is to explicitly close the elements I want closed, then close the base stream (Not the XmlTextReader). This works but IMO its a little hackey since the code in the Close() method could potentially change in the future and you could end up circumventing some code that you might want executed when your done with the reader.

.NET | C# | VB.NET | XML/XSL
Thursday, April 12, 2007 7:01:42 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Monday, March 26, 2007

I recently reconnected with my yearbook teacher from high school, Jonathon Siminoe, and learned that he is now teaching in Thailand. I highly recommend checking out his blog and short stories. He is an excellent writer and I find myself checking his blog every morning, coffee cup in hand, to read about his adventures in this Southeast Asian country. To whet your appetite, may I suggest Coffee House Run and Damn Shiny Car Wash? Great stuff!

Monday, March 26, 2007 2:12:49 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Friday, March 23, 2007

I have been working with the new custom configuration classes in .NET 2.0 and they really make creating custom xml configuration a snap. They are a little quirky to use at first but once you get past the initial learning curve they really make the job a lot easier.

One thing I really wanted to figure out is how to use these new classes to read files other than the default app/web.config. For example if you have one config file that might be shared between exes or if a config file is pulled from a URL. Its actually pretty easy to do.

First create your custom configuration file. It will look exactly the same as a web/app.config file except it will only contain your custom section(s). Create a section handler element identifying the custom section handler and the name of the section. Again, nothing different from doing this in the app/web.config.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <configSections>
  <section name="mySettings" type="CustomConfigHandler.MySettingSection, CustomConfigHandler"/>
 </configSections>
 <mySettings>
  <someSetting someAttribute="This is an attribute value from Settings1.config"/>
 </mySettings>
</configuration>

Next create a Configuration object that points to your file by passing in an ExeConfigurationFileMap with the ExeConfigFilename set.

// Create an exe file map containing the path to your config file
ExeConfigurationFileMap FileMap = new ExeConfigurationFileMap();
FileMap.ExeConfigFilename = "MySystem.config";

// Create a configuration object that is tied to your custom config file.
Configuration Config = ConfigurationManager.OpenMappedExeConfiguration(FileMap, ConfigurationUserLevel.None);

// Create the custom config section handler
MySettingSection MySettings = (MySettingSection)Config.GetSection("mySettings");

Console.WriteLine(MySettings.SomeSetting.SomeAttribute);


The entire source can be downloaded here:

ExternalConfigFile.zip (40.24 KB)
.NET | C# | Configuration | VB.NET
Friday, March 23, 2007 8:30:17 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Friday, March 16, 2007

This is a very moving photo essay on the after effects of Chernobyl. Very sad to see how children were affected.

http://inmotion.magnumphotos.com/essays/chernobyl.aspx

Friday, March 16, 2007 7:23:32 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [2]  | 
Tuesday, February 27, 2007

Nice little util to extract the boot sector from an ISO or disk. The home page is located here or you can download from the link below:

bbie.zip (18.83 KB)

Here are boot sectors for a couple of OS's:

WIN_ME.zip (717.94 KB)
WIN_XP_PRO.zip (1.09 KB)
WIN_SVR_2003.zip (1.1 KB)

OS
Tuesday, February 27, 2007 6:24:15 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  |