Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are busy upgrading 2009 to 2011 and found an annoying difference between the TOM.Net API for both versions. If you try to create a TcmUri object with the single-argument constructor, and the value of the argument is null, the behavior is different:

// 2009
TcmUri uri = new TcmUri(null);
log.Debug("found uri " + uri.ToString());
// the log shows 'found uri tcm:0-0-0'

// 2011
TcmUri uri = new TcmUri(null);
// the code breaks here with exception 'Null is not allowed'
log.Debug("found uri " + uri.ToString());

Of course, we don't pass 'null' on purpose. But we have many situations where we configure a uri through a package variable. When the variable isn't in the package, we end up with the null value.

Did anyone encounter the same problem? If so, how did you solve it?

share|improve this question
up vote 4 down vote accepted

I thought the argument was always required. I guess it didn't always validate it correctly.

Anyway, you could check for null or TcmUri.IsValid before trying to parse it and use a default value of TcmUri.UriNull if you want it to work the same as before. That does require code changes but I don't see any way around that.

share|improve this answer
I was afraid this would be the answer, but thanks anyway! – Quirijn Mar 25 '14 at 14:49

To handle all types of TcmUri issues, we have our own TcmUri class which handles

  • NullUri's
  • Implicit Operators

You can view @Rob code at TcmUri.cs.

share|improve this answer
Not sure how you can use a custom TOM implementation when rendering templates – Nuno Linhares Mar 25 '14 at 14:42
Thanks Siva. I would rather not re-do so much of SDL's own code. In my case (where I have access to the Tridion libraries) it would be more effective to have a wrapper class instead. – Quirijn Mar 25 '14 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.