Raise the SNR

August 12, 2009

Making MSDTC Work with Windows XP SP2

Filed under: Administration — admin @ 10:21 pm

Here’s the rundown on my most recent admin nightmare. I was helping to get Microsoft Distributed Transaction Coordinator working between 2 Windows XP SP2 boxes. These are development machines on which we wanted to prototype distributed transactions. In our case, we wanted to update 2 different SQL Server databases on 2 separate machines, and allow the updates to be committed on both systems in the case of success, or rolled back if an error occurred on either system. This is known as Two Phase Commit.

SECURITY WARNING!
The following changes could expose your system to security risks. This was implemented on development systems to test prototype code. If you need to make this work on a production system, please consult a qualified Microsoft Server Professional to implement MSDTC in your environment.

To make DTC work, a few changes have to be made to XP SP2. Here’s the list:

Open the following firewall ports

  • TCP Port 1433 (Default port used by SQL Server)
  • UDP Port 1434 (Used by SQL Server)
  • TCP Port 3372 (Used by MSDTC.EXE)
  • Add MSDTC.EXE to the firewall as an allowed program

Add the following entries to the registry if they don’t already exist in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\ClientProtocols – Found in MS Knowledge Base Article 325930

  • ncacn_http REG_SZ rpcrt4.dll
  • ncacn_ip_tcp REG_SZ rpcrt4.dll
  • ncacn_np REG_SZ rpcrt4.dll
  • ncadg_ip_udp REG_SZ rpcrt4.dll

Run dcomcnfg.exe to modify the security for MSDTC

  • Navigate to “Component Services\Computers\My Computer” in the tree view in the left-hand pane.
  • Right-click on My Computer and select properties
  • On the MSDTC tab, click on the “Security Configuration…” button
  • Change the security settings to match the following:
MSDTC Security Config Dialog

MSDTC Security Config Dialog

SECURITY WARNING!
The preceding changes could expose your system to security risks. This was implemented on development systems to test prototype code. If you need to make this work on a production system, please consult a qualified Microsoft Server Professional to implement MSDTC in your environment.

August 11, 2009

iCal on Mac OS X v10.4 and ics files

Filed under: Using Software — admin @ 11:24 pm

A little preface for this entry:

I have been developing on Microsoft platforms since the late  1980’s. However, I’ve always been fascinated with Apple products. So I decided to buy
a MacBook Pro. I can run Windows on a VM because it’s running an Intel processor, and I can experiment with the Mac and try my hand at developing for it.

That being said, I was registering for a Microsoft Developer event and was prompted to add the event to my calendar. Since iCal on the Mac can read ics and vcal files, I accepted. Then iCal displayed the following error:

“The calendar file is unreadable. No events have been added to your iCal calendar.”

Browsing the ics file in TextWrangler revealed the following:

BEGIN:vCalendar
VERSION:2.0
METHOD:PUBLISH
BEGIN:vEvent
DTSTART:20071201T230000Z
DTEND:20071202T010000Z
UID:11111111111
DTSTAMP:20071130T175905Z
DESCRIPTION: We look forward to seeing you at the Event!
SUMMARY:In-Person Event - Meeting
PRIORITY:3
BEGIN:vAlarm
TRIGGER:P0DT0H15M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:vAlarm
END:vEvent
END:vCalendar

I only found a couple of search hits on Google, but everything that I did find showed that certain key words were capitalized (strings after BEGIN: and END:). So I capitalized the strings after the BEGIN and END tags and tried to re-import the ics file. This time it was successful. I don’t know if there is a global specification for ics files, so I can’t say who’s to blame here. I do know that iCal expects VCALENDAR, VEVENT, and VALARM tags to be capitalized.

Trying to Create FxCop Rules for Source Code Analysis

Filed under: Development — admin @ 11:16 pm

I started working today on creating a rule in FxCop to enforce the use of curly braces on if and for statements. I know that FxCop is built to analyze IL, not source code, so this should be an interesting experience. I’ll blog about it if I’m successful.

UPDATE: I was correct about FxCop not reading the source code. So I was unable to enforce the curly brace rule. I was able to create a custom rule although it was a painful exercise.

The problem with custom FxCop rules is that Microsoft really doesn’t document how to do it. I sent an e-mail and got a very prompt reply from Brad Abrams, Krzysztof Cwalina, and David Kean. The final response I got about the curly braces was from David Kean:

Unfortunately, you will need to parse the source yourself, FxCop (even with the PDB) doesn’t provide enough information. Braces (like whitespace, comments, etc) are a source-only construct.

Here are some of the websites that I used to write the code.

http://weblogs.asp.net/rosherove/archive/2007/02/24/introducing-fxcopunit-a-framework-for-integrated-fxcop-rule-testing.aspx

http://blogs.interknowlogy.com/timmccarthy/archive/2007/02/13/11543.aspx

http://bordecal.mvps.org/Nicole/FxCop/CustomRuleDetails.htm

Accessing Underlying Data in ObjectDataSource – ASP.NET 2.0

Filed under: Development — admin @ 10:59 pm

I went around a few times on this problem today. I was pulling data into a GridView control from an ObjectDataSource. This ODS represented a Generic List of Data Transfer Objects that were populated using NHibernate. The DTO has a property that is really a foreign key into a reference table. The problem is that there are legacy portions of the system that still use the value of the foreign key as data. I know, I know, I should have refactored the relationship into the DTO. Time pressure being what it is, refactoring that portion of the system was not an option. Instead, I wanted to treat the “Order” field as a lookup into the list contained in a second ObjectDataSource. Then I would display the text for the lookup value in the GridView.

Since I dont yet know the internals of databound controls and datasources, I couldn’t find a way to access the data in the ODS programmatically. So, I came up with a huge hack instead. I decided that I needed functionality that looks like a DropDownList control. I had the value in the DTO, and I wanted the human readable text like the Text in a DropDownList. So I created an invisible DropDownList on my page that was bound to a second ObjectDataSource containing the reference data I needed. Then, I set the SelectedValue of the DropDownList to the Order property in the DTO. Finally, I returned the SelectedText of the DropDownList from a protected method that was called using Eval in the GridView’s databound column.

This works, and is much more performant than my first attempt, but there’s got to be a cleaner way to get the desired results.

Problems with ASP on Win2003 Server

Filed under: Administration — admin @ 10:50 pm

A friend called me today about a problem he was having with Win2K3 Server. He was receiving a 404 Page not found error when trying to GET a simple ‘hello, world’ ASP page. When we looked in the W3SVC IIS Logs, the error was a 404 2 1260, which indicates “404.2-Lockdown Policy Prevents This Request” 404 Description

Then we found out that ASP had to be enabled through the IIS Manager Enabling ASP in IIS 6

It’s difficult going from an environment like XP or 2K Server, which is wide open, to 2K3, which is locked tight out of the box. Hope this post helps someone.

Powered by WordPress