What’s a Tridion Circular Reference and why worry about it? As it’s name suggests, it’s a link that results in a circle of endless self-referencing. This normally isn’t a problem…unless you have a template that does a loop through all the fields, and all the fields it contains, and the ones that the linked one contains, etc. You get the point…it’s possible to have a never-ending loop of links to ourselves. This happened recently on a project where we had a Multimedia Schema, with a Metadata field allowing the same Mutlimedia Schema (relatively sane, right?) for a mobile variant of the image. Then someone linked to itself (I guess they didn’t have a special Mobile version, and felt they must put something in the field) and then our looping template did its best to find all the linked items, and well, it died every time we published a page with this special scenario.

The error message we got was:
Faulting application name: TcmPublisher.exe, version: 7.1.0.1290, time stamp: 0x527d103f
Faulting module name: System.Xml.ni.dll, version: 4.0.30319.18033, time stamp: 0x50b5aabe
Exception code: 0xc00000fd
Fault offset: 0x0000000000178ab2
Faulting process id: 0x8d4
Faulting application start time: 0x01cfc009cc4fea09
Faulting application path: D:\Tridion\bin\TcmPublisher.exe
Faulting module path: C:\Windows\assembly\NativeImages_v4.0.30319_64\System.Xml\4334f45efbe62a6415f2cb7393c59f74\System.Xml.ni.dll
Report Id: d1521031-2c31-11e4-9507-0a7ec577d18d
Faulting package full name: 
Faulting package-relative application ID:

The fix I am using involves creating an Event System solution to detect OnComponentSave, in the initiated phase, if the Multimedia Component’s MobileImage field links to itself.

And if so, throws an exception, not allowing the content to be saved. And in the process, we save the Publishing Renderer from exhausting itself with endless links.

Code: