Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

Bitten by UserData

I have written some custom activities for WF, but have recently found a bit of a problem with my implementation. I have wanted to persist information against the workflow instance that contains my custom activity (or many instances of the custom activity). I thought I was being very clever by resolving the owning workflow and then storing my information against the workflows UserData IDictionary property.

Even the description of the UserData property sounded appropriate according to my good intentions.

Gets an IDictionary that associates custom data with this class instance.

The problem that came up was that the data put into this property was persisted between multiple calls to execute the workflow type in the workflow runtime across any user that called it. I have had to change my implementation to store the data elsewhere to avoid this issue.

Read More

WF and missing build output from referenced project

Ever come across a WorkflowValidationFailedException at runtime even though the project containing the workflow was successfully validated and compiled without any errors? The reason for this occurring is how the compiler manages references.

Lets look at a simple solution that contains ProjectA, ProjectB and ProjectC. ProjectA references ProjectB which then references ProjectC.

ProjectA contains a form that references ClassB in ProjectB like this:

Read More

Code generation rules

Paul Stovell has posted some great points about the usage of code generation. This is of great interest to me because I am using code generation to produce a base service implementation as I develop an SOA application. I have a couple of thoughts to add to his list:

7. Code generation is not a license to avoid unit testing.

There is a tendency to not test generated code because the original unit testing of the templates was successful. Once you have generated code, it should now be considered alive in that it will be run in an environment, interact with other systems and will be required to work with data that didn’t exist in the code generation templates or their original test scenarios. Anything could cause problems because specific circumstances weren’t considered as the template was developed.

8. Code generation does not produce a product.

This point aligns with Paul’s 5th and 6th points. Code generation being a tool, shouldn’t produce a product. Use code generation to output common base level code that can then be customized and built upon. Code generation output can be the basis of a product, but shouldn’t be the entire product. If you have done this, then either you have wasted too much time on your templates, or your product design needs some serious CPR.

On a side note, the code generator I decided to use SmartCode because it is the easiest to use and understand in the freeware market. It is also open source so I can deal with any issues or restrictions that I come across. I have since also started to contribute my changes to the project.

Read More

What are the best refactor and profiler tools for VS2005?

If you have some experience with refactoring or profiling tools (preferably with experience of multiple tools), I would be really interested to know what you think.

For refactoring tools, the pick seem to be either JetBRAINS ReSharper or DevExpress RefactorPro. ReSharper is $250 and seems to have similar functions to RefactorPro which weighs in at $99 with free updates for a year, or $250 if bundled with CodeRush. There is also JustCode and C# Refactory but these both seem to be less mature compared to ReSharper and RefactorPro.

Read More

Misfire on the keyboard

Every now and then, and sometime more often than that, I happened to not have my fingers on the right keys. The results are usually terrible, but can sometimes be kinda cool. I just tried typing “similar” and came up with “sunukar” instead. Maybe that should be the name of my next piece of software.

Following in one of the trends of Microsoft, I have been naming software according to town names. Could this be the new method of generating code names? Just bash the keyboard in semi-random positions.

Read More

ASMX interoperability with WCF

If you have an ASMX client, you can get it to call a WCF endpoint with some restrictions. You have to use the basicHttpBinding on the WCF service and the service implementation (or contract) needs to be decorated with the XmlSerializerFormat attribute.

I have encountered a problem under SSL though. I am wanting to use username/basic authentication with the service over SSL. This article makes the following reference:

The easiest straightforward way for a successful interoperability scenario is to leverage on transport-layer security. This also means that a properly configured WCF implementation can interoperate with a Basic Profile 1.0 compliant ASP.NET Web Service (ASMX) that is currently deployed via SSL / HTTPS as well as with a WSE 2.0 service or client and likewise.

WCF has a standard binding called “<basicHttpBinding>” which derives its name from the Basic Profile specifications. There is a security mode within this binding called “TransportWithMessageCredential”. You can choose either a transport or a message credentials in this security mode. Setting it to <message clientCredentialType=”UserName”/> uses Transport-Level Security (SSL / HTTPS) with SOAP-Level Username token security credentials. This is in accordance with the WSS SOAP Message Security Username Token Profile 1.0 and it implements WSS SOAP Message Security 1.0 specification for username/password (for client authentication) over HTTPS (for privacy).

Read More

Free digital certificates from StartCom/StartSSL

I was doing some reading a while ago about digital certificates. The kind of certificate I was after was so that I could use HTTPS in IIS. It looked like the certificates were all very expensive for what they are. I finally came across a post that referred to StartCom. These guys offer free digital certificates for domain or email validation. At this stage, the only hitch is that the CA certificate is not on client machines by default, but can be installed from the StartCom site.

Check it out here.

Read More

How TFS stores workspace information

Given the recent problems on CodePlex, I have had to change the TFS server that one of my projects is hosted on. I found this to be a problem because I wanted to use the same directory for the source on my local drive. Even after removing the source control bindings and removing the TFS server settings, Visual Studio still complained that the directory is configured for the old server address.

TFS stores workspace directory mapping information in a VersionControl.config file located in _C:\Documents and Settings[YOUR PROFILE]\Local Settings\Application Data\Microsoft\Team Foundation\1.0\Cache_. The old server isn’t removed from this configuration when you remove the server from TFS in Visual Studio. This bit, you have to do yourself.

Read More