Dot Net Tips and Tricks

Custom Search

DTC and Windows Workflow Foundation Troubleshooting

Having recently spent several hours trying to configure DTC to communicate between my Windows XP workstation and a Windows 2003 Server, I recommend the following article for success. There are some security changes that occur in SP2 for Windows XP that require configuration before the two boxes will sucessfully talk.

My earlier article on the use of DTCPing for testing in the trackback will get you up to speed with this utility.
Set the appropriate values for the EnableAuthEpResolution and RestrictRemoteClients options on Windows XP SP2Set the appropriate values for the EnableAuthEpResolution and RestrictRemoteClients options on Windows XP SP2

Windows XP SP2 enhances security by requiring authenticated calls to the RPC interface. This functionality is configurable through the EnableAuthEpResolution and RestrictRemoteClients registry keys. To ensure that remote computers are able to access the RPC interface on a Windows XP SP2 computer, follow these steps:

Warning
Incorrect use of Registry Editor may cause problems requiring you to reinstall your operating system. Use Registry Editor at your own risk. For more information about how to back up, restore, and modify the registry, see the Microsoft Knowledge Base article “Description of the Microsoft Windows registry” at Description of the Microsoft Windows registry.

  1. Click Start, click Run, type regedit.exe, and then click OK to start Registry Editor.
    Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT
  2. Under the RPC key, create the following DWORD entries with the indicated values. If the RPC key does not exist then it must be created.

    DWORD entry Default value Recommended value
    EnableAuthEpResolution 0 (disabled) 1
    RestrictRemoteClients 1 (enabled) 0

  3. Close Registry Editor.

For more information about the RPC Interface Restriction functionality in Windows XP SP2, see the RPC Interface Restriction section of Changes to Functionality in Microsoft Windows XP Service Pack 2.

Link to the article: DTC Troubleshooting

No comments

Dot Net Framework 3.0 RTM

Yeah!!!! it’s finally RTM.. I’ve worked with Windows Workflow Foundation throughout the beta program and I find it to a real accet to the several projects I’ve used the foundation in. The tracking store and monitor support for runtime applications is wonderful for showing the progress of business transactions to end users.

Do yourself a favor and try the new .Net Framework out. HERE

No comments

CSharp Text Parser to String Variable

I regularly find myself creating constant strings or including Sql statements in c# source files. I like everyone else hate sitting there putting quotes around the lines of text, so I setup a web page with a parser to do it for you.

Very easy instructions.

  • Specify the name of the variable you want to use.
  • Paste or enter the text into the Input Code text area.
  • Hit convert.
  • Copy rendered code from Output Code text area.
  • Your done.

Simple easy and works for almost all strings. I’ll be adding special character support and fixed width wrapping soon, but give it a try and see if it doesn’t save you some time.

I’ve added a link at the top of the page or here.

Whoops…. BUG in firefox doesn’t see the line breaks correctly. I’ll be testing and fixing this weekend.

No comments

Windows Workflow Foundation DTC Configuration Troubleshooting

Having spent some time working with WF ’s SqlTrackingService and SqlWorkflowPersistenceService to work with Sql Server 2005 on a seperate machine, I’ve put together a few links to help others.

NOTE: Certain transactions in Windows Workflow Foundation are promoted to DTC transaction when the stores are located on different machines.

  • I found that the most helpful tool was DTCPing.
    • A very easy program that can be used to test firewall issues and the simple connection between 2 computers over DTC.
  • The second and more comprehensive was DTCTester.
    • This will simulate a full sql transaction between computers.
1 comment

CSharp IExtenderProvider with ExpandableObjectEditor for ValueLists

I’ve recently found a solution to a common problem of form development. Value lists or “CodeSets” for controls on user forms. Most of the time a programmer will write a stored procedure or statement to return some dataset and bind the results to a combo box, listview or similar control. I have several problems with this pattern.

  • Can cause multiple queries to the database for a single form to load.
  • Requires the programmer to write code for every control with an associated lookup table or value list.
  • Could be implemented inconsistently.

What are our goals?

  • Should require no code on the part of the programmer.
  • Should cache the values of the codesets at runtime to avoid multiple database queries.
  • Should be expandable to show both the name and id of the codeset.

So let’s solve this problem. I’m using Enterprise Library’s cache manager for caching and also EntLib’s data libraries for data access.

You’ll need 2 tables in the database:

  1. Codesets: The list of codeset identifiers and their descriptions.
  2. Codeset_Details: The list of values, it’s display value and the codeset identifier.

We create a custom component that implements IExtenderProvider that exposes a property called Codeset of type CodesetProperty.

Figure 1

The CodesetProperty class has a int and string member to store the id and name of the codeset to load into the control.

Figure 2

We need a custom typeeditor to show the available codeset values. NOTE: You will need to ensure you have access to the connection string for the current database. I do this through a registry setting pointing to our standard development directory which contains our app.config.

Figure 3

The last part is a custom typeeditor to return an InstanceDescriptor which the CodedDomSerializer will use to generate the Intialization code.

Figure 4

We then add a CodesetProvider to a form. In my case any combobox, listbox, dropdown and comboeditor will show a property “Codeset on codesetProvider1″. This is an expandable property so you’ll see the values listed but by dropping down the list on the property you will get a list of the available codesets and then at runtime this property will be used to load the combo box with the values.

No comments

Service Broker An easier way: Service Listing Manager

I just found this great thread:

An easier way: Service Listing Manager
Setting up Service Broker routes, endpoints and security is just too hard. One has to run pages and pages of Transact-SQL code just to get the ‘Hello, world’ example work between two separate SQL Instances and the chances of making a mistake are overwhelming.

Well, not anymore! I’ve just uploaded into the Service Broker team code gallery a new GUI tool for doing just that: easily configure two services to be able to have conversations. The tool uses the ‘Service Listing’ concept. A Service Listing is like an identity card for a service. It is an XML document that contains all the necessary information needed to establish a conversation with that service. When two parties need to establish a conversation, they can exchange the Service Listings of the two services and the tool will create the entire infrastructure needed to establish the conversation. Optionally it can also create the message types and contracts supported by a target service in the initiator service database….

Here is a link to it:
Service Listing Manager

No comments

Notification Services Conversation Cleanup

While testing a Notification Services install I found I had alot of dead conversations left in my SYS.CONVERSATION_ENDPOINTS

DECLARE @HANDLE UNIQUEIDENTIFIER
DECLARE C CURSOR FAST_FORWARD FOR SELECT CONVERSATION_HANDLE FROM SYS.CONVERSATION_ENDPOINTS
OPEN C;
FETCH NEXT FROM C INTO @HANDLE;
WHILE @@fetch_status = 0
BEGIN
END CONVERSATION @HANDLE WITH CLEANUP
FETCH NEXT FROM C INTO @HANDLE;
END
CLOSE C;
DEALLOCATE C;
GO

You would need to add a check to make sure the timeout period has expired but this works nicely to cleanup any outstanding conversations.

For more info: Microsoft Blog Post

No comments

Service Broker Fire and Forget Messages

I ran into the problem where I would send messages to the a remote service and the xml validation would fail. After checking the intiator side I couldn’t find an error message being returned from the receiving end. No event logs, nothing inserted into my error table… nothing. This got me digging around and I found a serious bug in my code.

I had purchased the Rational Guide to Service Broker 2005 by Roger Wolter and his pattern details the following:

DECLARE @conversationHandle uniqueidentifier

Begin Transaction

– Begin a dialog to the Order Service
BEGIN TRY
BEGIN DIALOG @conversationHandle
FROM SERVICE [TestCarolina_Message_Service]
TO SERVICE ‘Carolina_Message_Service’
ON CONTRACT [CarolinaOnly_Contract]
WITH ENCRYPTION = OFF, LIFETIME = 600;

– Send a message on the dialog
SEND ON CONVERSATION @conversationHandle
MESSAGE TYPE [msg_to_carolina]
(@Message)

END CONVERSATION @conversationHandle

END TRY
BEGIN CATCH
ROLLBACK
INSERT GENERAL.ERRORS (ERROR)
VALUES( ERROR_MESSAGE())
– Reenable queue
ALTER QUEUE TestCarolina_Message_Queue WITH STATUS = ON
END CATCH

commit

There is one glaring problem with this pattern. If an error happens on the receiving side, the conversation has already been ended on the sender’s side. When the Error is sent from the receiver, the message gets dropped, No EventLog, nothing. The conversation that the receiver is sending on does not exist on the sender anymore.

This leaves the question, how do we cleanup the conversation? Allow the receiver to end the conversation rather than explicitly end in on the sender. This requires the addition of an activated procedure on the sender’s queue that will handle the end conversations, but it adds the ability to handle error messages also. The following in pattern would be the correct way:

CREATE PROCEDURE usp_Message_Queue_Activation
AS
DECLARE @dh UNIQUEIDENTIFIER;
DECLARE @message_type SYSNAME;
DECLARE @message_body NVARCHAR(4000);
BEGIN TRANSACTION;
WAITFOR (
RECEIVE @dh = [conversation_handle],
@message_type = [message_type_name],
@message_body = CAST([message_body] AS NVARCHAR(4000))
FROM [InitiatorQueue]), TIMEOUT 1000;
WHILE @dh IS NOT NULL
BEGIN
IF @message_type = N’http://schemas.microsoft.com/SQL/ServiceBroker/Error’
BEGIN
INSERT Service_Broker_Errors
(error, [message]) values(N’Received error %s from service [Target]‘, @message_body);
END
END CONVERSATION @dh;
COMMIT;
SELECT @dh = NULL;
BEGIN TRANSACTION;
WAITFOR (
RECEIVE @dh = [conversation_handle],
@message_type = [message_type_name],
@message_body = CAST([message_body] AS NVARCHAR(4000))
FROM [InitiatorQueue]
), TIMEOUT 1000;
END
COMMIT;
GO

– Create queue for messages to go to
CREATE QUEUE Test_Message_Queue
WITH ACTIVATION (
STATUS = ON,
MAX_QUEUE_READERS = 1,
PROCEDURE_NAME = [usp_Message_Queue_Activation],
EXECUTE AS OWNER);
GO

This would allow errors that occur during transmission to be handled gracefully.

No comments

Colors in .Net

I found a nice page for finding the hex code of a particular color.

Colors in ASP.Net

Another nice option is the FireFox’s extension Colorzilla.

This provides a mouse pointer RGB representation of the color under the pointer.

No comments

Visual Studio Code Snippets Editor

Snippy

I recently stumbled across this little program for managing your code snippets in Visual Studio.

The program is called Snippy the Visual Studio Code Snippet Editor. It made creating common code snippets for my company a breeze. Check it out at Snippy.

No comments

« Previous PageNext Page »