Session.GetObject in Tridion 2011 returns a component for a nonexistent element

I am trying to figure out how to check if a component is null (e.g. not found in Tridion) in a custom backend. I just don’t see how to check this, except to catch the error.

Component comp = (Component)session.GetObject(base.ComponentUri);

if (component != null)
{
    bool isCheckedOut = component.IsCheckedOut;
}
else
{
    // how do I get in here!
}

I am 100% sure that uri is correct ('tcm: 113-438134') and 100% sure that there is no element with this URI in Tridion. The above code throws an error in the .IsCheckedOut component:

The item tcm:113-438134-16 does not exist.

How to check for a Tridion element? I tried to put a throw at the end, which did not help:

Component comp = session.GetObject(base.ComponentUri) as Component;

and I tried not to use at all, but using IdentifiableObject, which also didn't make any difference. Does anyone know how to do this?

+5
source share
1 answer

- Tridion. , URI . session.IsExistingObject(TcmUriOrWebdavUrl), , .

...

, ...

API TOM.NET , . Core Service API.

+10

All Articles