News

Set the PATH environment variable for .NET tools in your PowerShell profile

2008-08-05 11:07:41 by Kjell-Åke Andersson

To set the PATH environment variable for your PowerShell profile you have to do the following:

  1. Make sure you have a folder called WindowsPowerShell in My Documents.
  2. Create a file called profile.ps1 in the new folder and open it.
  3. Copy the following into the new file:
  4. $paths = @();
    $paths += $env:PATH;
    $paths += join-path (get-itemproperty "HKLM:SOFTWARE\Microsoft\Microsoft SDKs\Windows").CurrentInstallFolder "bin";
    $paths += join-path (get-itemproperty "HKLM:SOFTWARE\Microsoft\.NETFramework").InstallRoot "v2.0.50727";
    
    $env:PATH = [string]::Join(";", $paths);
  5. Close  the file.
  6. Open a new PowerShell prompt.

|

Debugging windows services

2008-06-27 08:45:52 by Kjell-Åke Andersson

When I need to debug a windows service I usually make a call to Thread.Sleep and then attach the debugger manually.

   1:  protected override void OnStart(string[] args)
   2:  {
   3:   
   4:      Thread.Sleep(10000);
   5:   

 

But now I have realized that there is an easier solution to this problem and it is to launch the debugger by yourself!

   1:          protected override void OnStart(string[] args)
   2:          {
   3:   
   4:              #if DEBUG
   5:              if (Properties.Settings.Default.Debug)
   6:              {
   7:                  System.Diagnostics.Debugger.Launch();
   8:              }
   9:              #endif

|

WiX Service Account Dialog

2008-05-30 09:21:41 by Kjell-Åke Andersson

In my current project we had a need to be able to enter the service account details during setup for the service which is hosting our WCF services. I couldn't find a dialog that does this using WiX so I created my own.

image

In my setup project I used the WIXUI_FeatureTree template as a base. To "hook in" the new dialog you will have to override the template because if you just add new Publish elements they will not override the existing elements.

 

   1:      <UIRef Id="WixUI_ErrorProgressText"/>
   2:      <UIRef Id="WixUI_Common" />
   3:   
   4:      <Binary Id="WarningIcon" SourceFile="warning.bmp"/>
   5:      
   6:      <UI Id="MyWixUI_FeatureTree">
   7:        <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
   8:        <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
   9:        <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
  10:   
  11:        <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
  12:        <Property Id="WixUI_Mode" Value="FeatureTree" />
  13:   
  14:        <DialogRef Id="ErrorDlg" />
  15:        <DialogRef Id="FatalError" />
  16:        <DialogRef Id="FilesInUse" />
  17:        <DialogRef Id="MsiRMFilesInUse" />
  18:        <DialogRef Id="PrepareDlg" />
  19:        <DialogRef Id="ProgressDlg" />
  20:        <DialogRef Id="ResumeDlg" />
  21:        <DialogRef Id="UserExit" />
  22:   
  23:        <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
  24:   
  25:        <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
  26:   
  27:        <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
  28:        <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg">LicenseAccepted = "1"</Publish>
  29:   
  30:        <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">Installed</Publish>
  31:        <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg" Order="2">NOT Installed</Publish>
  32:        <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="ServiceAccountDlg" Order="1">1</Publish>
  33:   
  34:        <Publish Dialog="ServiceAccountDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg">1</Publish>
  35:        <Publish Dialog="ServiceAccountDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
  36:   
  37:        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ServiceAccountDlg" Order="1">NOT Installed OR WixUI_InstallMode = "Change"</Publish>
  38:        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed</Publish>
  39:   
  40:        <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
  41:   
  42:        <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
  43:        <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
  44:        <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
  45:        <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
  46:   
  47:        <Dialog Id="ServiceAccountDlg" Width="370" Height="270" Title="[ProductName] Setup">
  48:          <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
  49:          <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
  50:            <Condition Action="disable"><![CDATA[ACCOUNT = "" OR PASSWORD = ""]]></Condition>
  51:            <Condition Action="enable">ACCOUNT &lt;&gt; "" AND PASSWORD &lt;&gt; ""</Condition>
  52:          </Control>
  53:          <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
  54:            <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
  55:          </Control>
  56:          <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
  57:          <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
  58:          <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
  59:          <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Enter service account details.">
  60:          </Control>
  61:          <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Service account" />
  62:          <Control Type="Text" Width="322" Height="26" X="25" Y="56" Id="BodyLabel" Text="Specify the logon account for the [ProductName] service." NoPrefix="yes">
  63:          </Control>
  64:          <Control Type="Text" Width="275" Height="10" X="25" Y="98" Id="AccountLabel" Text="&amp;Account name (Example: domain\user or user@domain):" />
  65:          <Control Type="Edit" Width="194" Height="15" X="25" Y="111" Id="AccountTextbox" Property="ACCOUNT" />
  66:          <Control Type="Text" Width="275" Height="10" X="25" Y="135" Id="PasswordLabel" Text="Pa&amp;ssword:" />
  67:          <Control Type="Edit" Width="194" Height="15" X="25" Y="148" Id="PasswordTextbox" Property="PASSWORD" Password="yes" />
  68:   
  69:          <Control Width="12" Height="12" FixedSize="yes" Type="Bitmap" X="25" Y="170" Id="Warning" Text="WarningIcon"/>
  70:          <Control Id="WarningLabel" Type="Text" X="40" Y="170" Width="200" Height="40" Text="The account entered here will not be validated. Make sure that the account details entered are correct." />
  71:        </Dialog>
  72:      </UI>

|

Purge the BizTalk Tracking Database

2008-05-14 23:40:51 by Kjell-Åke Andersson

We've had a problem with disk space our development server and one of the issues was that the BizTalk Tracking Database (BizTalkDTADb) grew to over 2 Gb. But tonight I found this great article on how to purge the database and to schedule the purging.

 

BizTalk Developers, have you enabled DTA Purge and Archive (BizTalkDTADb) SQL job on your development machine?

|

Great LINQ To SQL tips

2008-05-14 12:06:29 by Kjell-Åke Andersson

I found today a great article with 10 tips for using LINQ To SQL more efficient.

 

10 Tips to Improve your LINQ to SQL Application Performance

|

Never merge a dbml-file again!

2008-04-21 00:27:04 by Kjell-Åke Andersson

When you are using Visual Studio 2008 for development and Team Foundation Server 2005 for version control you should add the following rule to TFS in case you are using Linq To Sql.

image

This will make sure that your dbml-files cannot be checked out my multiple users and this will definitely help you as it is an absolute royal pain in the *ss to merge these files!

|

Open PowerShell Prompt Here

2008-02-17 10:57:13 by Kjell-Åke Andersson

I've been using PowerShell for a while now but it still hasn't replaced the command prompt for me yet. I have been using the "Command Prompt Here" Power Toy a lot to make it easier to open up a command prompt at a specific location from the explorer. So now I added some settings to the registry that will do the same but with PowerShell instead.

Here is the registry script for making such an entry in explorer:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\PowerShell]
@="Open PowerShell Prompt Here"

[HKEY_CLASSES_ROOT\Directory\shell\PowerShell\Command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoExit -Command [Environment]::CurrentDirectory=(Set-Location -LiteralPath:'%L' -PassThru).ProviderPath\""

|

What's wrong with this picture?

2007-12-11 09:16:52 by Kjell-Åke Andersson

While reading my bunch of daily blogs I found out that Microsoft posted an overview of service pack 3 for Windows XP. Of course this seemed like something that I would like to check out. But then when I got to the download page I was treated with the option to either download the document as an PDF or XPS. I don't have any special preference for any of these formats, but what's interesting is that the XPS is 114 kb larger than the PDF? This triggered me to compare the two documents too see what the XPS offered me over the PDF. As it turns out it is actually nothing more! The two documents contains the same information!

If Microsoft wants me to use their new document format, then why would I use it as it makes documents 34% larger (this is just an estimate)! I would have understood that it was larger if it had contained animations and music, but when the content is the same???

image

|

LLLLLLLLLLINQ!!

2007-11-27 09:46:09 by Kjell-Åke Andersson

I've played around some with LINQ now when .NET 3.5 is released and I have to say that I think it is great! LINQ will definitely be a great boost for smaller development shops and small IT departments where there is a need for a to build small internal applications quickly. For large scale development I'm not as sure if it will be used that much as there is already a lot of different solutions for handling the data access (CSLA.NET, nHibernate, SubSonic etc.).

I've also found the tool LINQPad which seems to simplify LINQ development. Here is a screenshot from it.

|