1

I am writing event code for Tridion R5 in C# but i am facing some challenges while implementing it in tridion. Is there any reference for Tridion R5 event system documentation or some sample code i can have?

Thanks

2
  • R5 are Visual Basic event systems, if you are using R5.3 you can use the TOM.NET interop (officially it was still only VB), so perhaps you can be a bit more specific on what version of Tridion you are exactly using? Please note that any of the R5 versions are end-of-life, so you shouldn't really be developing new stuff on it... Apr 13, 2015 at 8:16
  • Thanks for your reply Bart. I am using Tridion R5.3 and just firing a simple event using C#. Is it possible to write event system code using C# in Tridion R5.3 or VB is the only option to write event code in Tridion R5.3. Any reference documentation will be of much helpful. Thanks in advance.
    – SumitK
    Apr 13, 2015 at 9:03

2 Answers 2

2

You can write your 5.3 event system in C# as long as you make it Com-compatible (see https://msdn.microsoft.com/en-us/library/c3fd4a20.aspx).

Register it with regasm.

In your class, you can use the Tridion Interops to access the TOM.

2

From a very old thread on a very old (closed) forum...

If you do the following, Visual Studio will complete it for you:

  1. Add references to Tridion.ContentManager.Interop.cm_tom.dll, Tridion.ContentManager.Interop.cm_defines.dll and Tridion.ContentManager.Interop.msxml4.dll
  2. In your code:
using System;
using System.Xml;
using Tridion.ContentManager.Interop.TDSDefines;
using Tridion.ContentManager.Interop.TDS;
using Tridion.ContentManager.Interop.msxml4;

namespace yourNamespace.goes.here
{
  [System.Runtime.InteropServices.ComVisible(true)]
  [System.Runtime.InteropServices.ProgId("TDSEvents.Events")]
  public sealed class Events : ITCMEvents
  1. At this point Visual Studio will propose that you press TAB and it will create all the methods for you.

Be aware that events that happen to use MSXML2 objects will cause problems in .NET due to serialization issues between COM and .NET, unless you're running on .NET 1.1 (which I seriously doubt).

4
  • 1
    To add to this great answer, please note that when using COM through .NET you get a lot of potential (memory related) issues if not done correctly. Check out my answer here for some details on how to release these COM objects properly. Apr 13, 2015 at 12:03
  • Hi, I have added all the references given above in Step 1 and step 2 is also done. I am running my application with .Net 2.0 framework.
    – SumitK
    Apr 13, 2015 at 12:15
  • And is it working? Where are you stuck now?
    – Nuno Linhares
    Apr 13, 2015 at 12:43
  • +1 to Bart for pointing out the pitfalls of COM interop in .Net. Prepare to write Marshal.ReleaseComObject very, very often.... Apr 16, 2015 at 13:43

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.