4

For Tridion 2009 workflow we are using Event Triggers to listen for the event "activity instance is started". Within the code we have a method that gets triggered when this event is triggered.

The code works fine and we can get the this functioning correctly in the lower environments. However when we move into an environment with high traffic we run into the following error randomly and infrequently.

Unable to cast object of type 'System._ComObject' to type 'Tridion.ContentManager.Interop.TDS.TDSEClass'. Tridion.Extension.Utilities.Util.GetTDSE(String identity) at Tridion.Extension.Framework.Workflow.WorkflowEvents.OnActivityInstanceStartPre(ActivityInstance activityInstance) OnActivityInstanceStartPre.1 :: System.InvalidCastException: Unable to cast object of type 'System._ComObject' to type 'Tridion.ContentManager.Interop.TDS.TDSEClass'. at Tridion.Extension.Utilities.Util.GetTDSE(String identity) at Tridion.Extension.Framework.Workflow.WorkflowEvents.OnActivityInstanceStartPre(ActivityInstance activityInstance)

It looks like error seems to happen within the below code.

TDSE result = new TDSEClass() as TDSE;

This works most of the time but randomly we get this error.

Does any one know why this might be happening?

  • Since you only randomly get this error, does this means you randomly got this while accessing only the CME and not while debugging the associated code with it? – Pankaj Gaur Oct 22 '13 at 6:42
3

It may be that you are not releasing the TDSE object properly in your Events System code.

Jamie has an excellent SDL Tridion TOM Interops - Why don't you release me ?!?! post on this.

  • 1
    Please also consider reading my answer here just releasing the component and tdse objects as Jaime recommends might not be enough to properly release all used resources. – Bart Koopman Oct 21 '13 at 15:13
  • Thanks for the suggestions guys, the code does release the TDSE object at the end of the method. – Levikay Oct 21 '13 at 16:12
  • 1
    @Levikay perhaps you can share a bit more of your actual code then so we can focus on it in more detail? – Bart Koopman Oct 22 '13 at 7:23
2

Invalid cast exceptions are often a symptom of memory pressure on a system which is suffering a memory leak, perhaps in otherwise unrelated code.

So, yes - as others have suggested, free your RCWs. You need to make sure this also occurs when an exception is thrown, so also follow the advice that's been linked to about using using blocks (or perhaps finally blocks) when you are disposing.

But - just as important - get some monitoring running on your server. Perfmon will probably be the first tool to reach for to get started. Look for memory leaks... I'd start by graphing the private bytes on your publisher process (on the grounds that such leaks are often caused by buggy templates). As this is a workflow issue, I'd also monitor the memory in the workflow agent service, and of course the COM+ application.

When invalid cast exceptions are caused by a memory leak, you'll often see them happening in the run-up to a crash. Look in your event logs to see if they are happening just before out of memory exceptions. Correlate events in your logs with timing details from your perfmon logs. If this is the cause, you'll see these related symptoms.

1

Why are you using a TDSEClass and then trying to cast to TDSE?

Here is the code I typically use:

TDSE tdse = new TDSE();
tdse.Impersonate(WindowsIdentity.GetCurrent().Name);
tdse.Initialize();

And yes, don't forget to Dispose().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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