|
Friday, January 16, 2009
My article about The Future of Microsoft .NET Programming Languages just got published on InfoQ.This is my first attempt at being an editor for them, so if this works out I hope you will see more stuff from me in the near future. Would love to hear what you think, so drop me a comment if you like.
Saturday, December 20, 2008
Sunday, October 26, 2008
This is my fifth post in my WiX and DTF series. Here are some others I’ve written: After working quite a bit with Custom Actions (CA’s) in managed code I thought it was about time to show how we can debug CA’s. Before DTF it was almost impossible to step into your code written in C++, VB Script or Java Script and debug. With DTF this is simple, but still not 100% intuitive or straight forward. You have two options mentioned in the DTF documentation for debugging your code and a third which is not mentioned: - Use environment variable MMsiBreak (not to be confused with MsiBreak)
- Attach the debugger to the process via a message box
- Use System.Diagnostics.Debugger.Launch
Using MMsiBreak Here’s how to add MMsiBreak to your environment variables in Vista: - Start –> Right click Computer –> Properties (or navigate to Control Panel –> System)
- Select Advanced system settings
- Click Environment Variables…
- In the System variables section click New…
- Set Variable name = MMsiBreak
- Set Variable value = Name of your custom action method
On my computer it looks like this: In my example it will break for debugging when Windows Installer is executing the CA GetWebSites. When that happens you will get the following dialog: Select Yes and you will be prompted to select a debugger to use. If you already have your solution open in VS, you will get the option of using that. Note however that on Vista admin privileges is required, so you need to have your Visual Studio running as admin in order for it to bee listed in the below screen: When I select the running VS (as above I’ve done above) I get something in VS which I can’t quite explain. The first time this happened to me I thought it didn’t work. I get this message: The thing is that the source code is of course already displayed, but I thought there was some problems with loading the symbols. However, if you just click Ok and hit F5 (Start debugging) in VS, your breakpoint will hit. Just a thing to be aware of if you get this. Using Message Box By using a message box you can accomplish the same thing, but this requires changes to your code and a recompile of both your CA project and you WiX project. Personally I prefer the above method, but it’s always nice to have options In order to debug using message box you must: - Make sure you have a reference to System.Windows.Forms.dll.
- Somewhere in your code (where you want to break) add some code for displaying your message box. Something like this:
MessageBox.Show("Please attach a debugger.");
- Add a breakpoint somewhere in your code below your message box code
- Rebuild your CA project as well as you WiX project to get the new changes.
- Run your MSI.
- When the message box displays, go to Tools –> Attach to Process… (Ctrl + Alt + P)
- Find the process named rundll32.exe and attach.
- Click Ok on the message box in you installation.
- The breakpoint you set earlier should now be activated in VS
Using Debugger.Launch()
This is exactly the same as using MMsiBreak except you trigger it from code instead of a environment variable. Just add this line to your code where you want to debug:
System.Diagnostics.Debugger.Launch();
This will give you the same “Unhandled exception” dialog as before and the rest is the same.
The MSI log file
If you’ve been working with MSI’s you know this already, but I think this is something every developer/it-expert should know about and in my experience most people don’t. Sometimes when you run an MSI and get an error that maybe causes a rollback and you can’t get the installation to install, you’re stuck with a cryptic error message. If you’re lucky you can Google it and maybe find the problem (or solution), but often this is not the case. Then this little command might come in handy:
msiexec /i NameOfMSI.msi /l*v C:\Temp\install.log
The above command uses msiexec.exe which is what Windows uses when you double click on an msi. Actually Windows does exactly like the above except from the /l*v part and that’s where you tell msiexec to log to a file. Here’s what it means:
/l = Log
* = Everything
v = Verbose
You can skip the v and you will get slightly smaller log file. Personally I use v all the time.
Saturday, October 11, 2008
Earlier this week I posted a question on the WiX user list. The question was: Which version of WiX is being distributed with Visual Studio 2010? As you probably know by know (at least if your interested in msi and deployment) is that WiX will ship as part of Visual Studio 2010. To make a long story short, the answer is 3.0. This was expected, but I was still curious. Having WiX v. 3.0 with VS means that all developers have the option to create advanced installations using Windows Installer, and also to create Custom Actions (CA’s) in managed code!
Tuesday, May 27, 2008
Brian Harry over at the TFS team has a great post about the new features that will be available in the coming SP1 for TFS 2008.
Friday, April 18, 2008
Today I had a problem. At work we had a SCSI Raid controller that failed and we lost a logical device. Man I was pissed off! On top of this the raid was RAID 0 (striped), meaning there was no chance of getting any data back. This was the drive(s) hosting the OS which we had to reinstall :-( Anyway, this resulted in me having to spend quite some time in a freezing and noisy server room fixing the problems. While doing stuff like this (reinstalling OS, software and a pointless effort of restoring data) there is a bit of waiting time, so I figured I might as well work on our new server waiting to get TFS 2008 up and running. A brand new server (see spec below) dedicated to protect the heart of our company; the source code! So I started digging around for the TFS 2008 DVD, knowing it should be on my desk with the MSDN subscription we get through the Microsoft Gold Partner program, but it was nowhere to be found. After a call to MSDN it turns out that the DVD's are now being shipped to our headquarters in Oslo, which was the case for TFS 2008 as well, but they couldn't find it. The guy who knew was of course away that day. You might wonder why not download? Well, you can't. TFS versions available on MSDN subscription is only Workgroup and trial editions. My last attempt before giving the whole thing up was calling my friend John from NNUG and ask if they had a DVD I could use. He had a much better idea: "Just use the trial and upgrade with your key at a later time". Dooh! Why didn't I think of that. Check out Brian Harry's blog for more details: http://blogs.msdn.com/bharry/archive/2007/11/22/2008-installation-questions.aspx Server spec: - HP ProLiant DL380 G5 Intel® Xeon® E5440 Quad Core Processor 2.83 GHz 12MB 2GB 1P Rack Server
- HP 4 GB PC2 5300 DDR2 DIMM Memory
- 6 HP 72GB 2.5 inch 15K rpm Hot Plug DP SAS Hard Drives
- 2 HP 146GB 2.5 inch 10K rpm Hot Plug DP SAS Hard Drives
I think this should keep our source code safe for a while...
Tuesday, February 26, 2008
You might argue both, but that's beyond the point I've been thinking lately about how different programmers get their work done. If you look over the shoulders to 3 programmers, none of them is working the same way. The first difference I tend to notice is the use of keyboard shortcuts. Personally I've always been a fan of shortcuts, especially in development environments like Visual Studio, but also general shortcuts in Windows or other applications. For instance I never do File -> Open. I always use ctrl -> O and it always annoys me when a program does not support the most common shortcuts. However, I still feel I can learn and use more of them. We can divide developers into three groups related to the above: - Love the mouse and rarely use shortcuts
- Use mouse often, but use shortcuts for the most common actions
- Use the mouse only when there's no shortcut for the action.
I think I can put myself in category 2 and I'm not sure if I want to or are able to be in category 3. One important aspect to consider before I dig myself to deep into this, is that you don't necessarily produce better software by using a lots of shortcuts (obviously). However I'm quite sure that a developer in group 3 produce code faster than a group 1 developer. But one can argue (if you're a bit extreme) that the quality of the code produced by group 1 is better, because they get more time to think But seriously you can't use this type of groupings for defining developers, but in general I think many developers could benefit from using more shortcuts. Here are the most common shortcuts in Visual Studio 2005 as I see it:
| Builds | | | Ctrl+B, Ctrl+S | Build | BuildSelection | Ctrl+Shift+B | Build | BuildSolution | Ctrl+Break | Build | Cancel | | | | | | Debugging | | | | F5 | Debug | Start | | Ctrl+F5 | Debug | StartWithoutDebugging | | Shift+F5 | Debug | StopDebugging | | F10 | Debug | StepOver | | F11 | Debug | StepInto | | Ctrl+F10 | Debug | RunToCursor | | Shift+F11 | Debug | StepOut | Ctrl+Shift+F10 | Debug | SetNextStatement | F9 | Debug | ToggleBreakpoint | | Ctrl+Shift+F9 | Debug | DeleteAllBreakpoints | | | | | | Navigation | | | | F12 | Edit | GoToDefinition | Ctrl+F12 | Edit | GoToDeclaration | | | | | | Other | | | | Shift+Alt+Enter | View | FullScreen | | Ctrl+Shift+F12 | View | NextError | | Ctrl+Alt+P | Tools | AttachtoProcess | | Shift+Alt+A | Project | AddExistingItem | | Ctrl+K, Ctrl+M | Edit | GenerateMethodStub | You probably know where and how already, but if you go to Tools -> Options -> Keyboard in Visual Studio you can define your own shortcuts. This is a great feature of Visual Studio that let you create custom shortcuts for almost every action you can do with a mouse. You can either change an existing shortcut or define new ones. Here's a screenshot of the shortcut dialog in VS: Commands are displayed alphabetically after some type of menu structure (e.g. Edit.Copy), though there a many more commands than you can find in the menu. This list is of course populated dynamically which means you'll find commands for 3rd party VS plugins like e.g. ReSharper. One thing to be aware of though is existing shortcuts. If you for instance want to have the shortcut Ctrl+V, Ctrl+A, you will override the Ctrl+V command for Paste, which is probably not what you want.
Wednesday, November 21, 2007
 You probably know allready, but Visual Studio 2008 is now available on MSDN Subscriptions for download. If you don't have an MSDN Subsription I'm afraid you'll have to wait until February 2008...
Monday, November 05, 2007
Sunday, August 19, 2007
If you are like me you probably have a hard time finding something to create when trying out new stuff. This time I sat down and tried to figure out something to use LINQ and Silverlight for and maybe WCF, WPF and Ajax as well. At the time I was watching TV and the EPG (Electronic Programming Guide) didn’t work, so I started to look for a web site with a program guide supporting reminders and other nice features to let you know what’s on TV. I didn’t find anything good. I then started to look for an xml/text format for TV programs. I did some searching and came across xmltv. Nice! I now had an xml source looking something like this:
<tv>
<channel id="channel1">
<display-name lang="nb">Channel 1</display-name>
</channel>
<channel id="channel2">
<display-name lang="en">Channel 2</display-name>
</channel>
...
<programme start="20070801033000 +0200" stop="20070801053000 +0200" channel="channel1">
<title lang="nb">Program 1</title>
<desc lang="nb">Program description.</desc>
<credits>
<director>...</director>
<actor>...</actor>
<actor>...</actor>
</credits>
<date>2004</date>
<category lang="en">movie</category>
<category lang="en">drama</category>
</programme>
...
</tv>So now I had an xml document containing all the data I needed
and this was a perfect time to try out XLINQ. I decided to stick with the LINQ
query syntax and not mix in Lambda expressions to keep things simple and
readable. I came up with this expression to get all TV channels:
public List<TvChannel> GetTvChannelsWithoutGuide() { IEnumerable<TvChannel> channels;
try {
XElement tvGuide = XElement.Load(_xmlFileLoc);
channels = from c in tvGuide.Descendants("channel") orderby (string)c.Element("display-name") ascending select new TvChannel { Id = (string)c.Attribute("id"), Name = (string)c.Element("display-name"), Lang = (string)c.Element("display-name") .Attribute("lang"), TvGuideLoaded = false }; }
catch (FileNotFoundException fileNotFoundEx)
{
throw new FileNotFoundException( string.Format("Xml file for tv guide not found at {0}", _xmlFileLoc), fileNotFoundEx);
}
return channels.ToList<TvChannel>();
}
The XElement gives me the complete xml document that I can
use XLINQ expressions on. In my query I’m looking only for TV channels, so I
specify that in the query by from c in tvGuide.Descendants("channel")This gives my a variable c that I use in my orderby clause and select statement. The orderby clause
orderby (string)c.Element("display-name") ascendinguses the c variable to access the “display-name” element to set order by. But it’s the select statement which is the cool thing here! First here a listing of the TvChannel class: [Serializable] public class TvChannel
{ public string Id { get; set; }
public string Name { get; set; }
public string Lang { get; set; }
[XmlIgnore] public IEnumerable<TvProgramme> TvGuideNonSerializable {
get { return TvGuide; }
set { TvGuide = value.ToList(); }
}
public List<TvProgramme> TvGuide {
get;
set;
}
public bool TvGuideLoaded { get; set; }
} Ignore the TvGuideNonSerializable property for now. By using select new TvChannel I can create an object of my TvChannel class an assign data from the xml document to my properties. I just love this syntax! It’s really nice and easally understandable. Another cool feature (running VS 2008 Beta 2) is that you get ItelliSense in LINQ for your classes, like this:  I also created other methods for retrieving all programs for one channel, all channels etc. At the time of writing I’m working on a Silverlight implementation for the TvGuide which I hopefully can show you soon. And later I’ll make all source code available.
Thursday, July 12, 2007
Yes,
it’s important to distinguish between the two. At the partner conference in
Denver Kim Saunders (Senior Director, SQL Server Marketing) said that they
launch SQL Server 2008 in February, but the actual release will be in Q2. And
by launching they mean that they have all the marketing material and the final
product information, but not the product.
As for Visual Studio and Windows
Server I have not yet heard anything similar, so I'm still thinking 27th for these.
Tuesday, July 10, 2007
Update: At TechEd Barcelona Microsoft announced today (2007-11-05) that Visual Studio 2008 and .Net Framework 3.5 will release in late November. See the official press release here: http://www.microsoft.com/presspass/press/2007/nov07/11-05TechEdDevelopersPR.mspx
I’m at the Microsoft Partner Conference in Devner where
Microsoft just announced the release date for Visual Studio 2008, SQL Server
2008 and Windows Server 2008. Look forward to February 27!
Sunday, April 22, 2007
Wednesday, January 24, 2007
 Don't forget to register for MSDN Live in Bergen 13. February! It's no surprise that Ajax and IIS 7 attract a lot of people to this event, so register now before it's full. You don't want to become the guy, who wasn't there, would you? ;) You can even pick up some Tips & Tricks for VS 2005. If this Tips & Tricks session is the same as at TechEd, you'll have to see it!
Wednesday, January 17, 2007
Friday, December 15, 2006
During the day I found two new releases. Asp.net Ajax RC is out ( http://ajax.asp.net/) and Visual Studio 2005 SP1 is released ( http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx). I vote for Monday releases, so we can get paid testing them. Since I can’t keep my hands off these two, my weekend is ruined! :) Enjoy! Update: You might want to have a look at Scott Guthrie’s blog before running the installation. He has some tips you should have a look at. Both for pre Vista and Vista operation systems. You'll find his post on vs sp1 here and vista here.
|
| |
|
|
|
|
| |
| March, 2010 (1) |
| February, 2010 (3) |
| January, 2010 (4) |
| December, 2009 (1) |
| August, 2009 (4) |
| July, 2009 (4) |
| June, 2009 (2) |
| May, 2009 (4) |
| April, 2009 (7) |
| March, 2009 (7) |
| February, 2009 (4) |
| January, 2009 (4) |
| December, 2008 (7) |
| November, 2008 (1) |
| October, 2008 (6) |
| September, 2008 (7) |
| August, 2008 (4) |
| July, 2008 (3) |
| June, 2008 (7) |
| May, 2008 (7) |
| April, 2008 (5) |
| March, 2008 (3) |
| February, 2008 (9) |
| January, 2008 (3) |
| December, 2007 (4) |
| November, 2007 (10) |
| October, 2007 (10) |
| September, 2007 (2) |
| August, 2007 (6) |
| July, 2007 (6) |
| June, 2007 (3) |
| May, 2007 (2) |
| April, 2007 (8) |
| March, 2007 (6) |
| February, 2007 (5) |
| January, 2007 (10) |
| December, 2006 (9) |
| November, 2006 (5) |
| October, 2006 (8) |
| September, 2006 (5) |
|
|
 |
 |
|
|