2

Am facing a problem, while creating components through TOM API using .NET/COM Interop.

Actual Issue:

I have 550 components to be created through custom page. I am able to create between 400 - 470 components but after that it is getting failed and through an error message saying that

Error: Thread was being aborted.

Any idea / suggestion, why it is getting failed?

OR

Is there any restriction on Tridion 2009?

UPDATE 1:

As per @user978511 request, below is error on Application event log:-

Event code: 3001 
Event message: The request has been aborted. 
...
...
Process information: 
    Process ID: 1016 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: HttpException 
    Exception message: Request timed out. 
...
...
...

UPDATE 2:

@Chris: This is my common function, which is called in a loop by passing list of params. Here am using Interop dll's.

    public static bool CreateFareComponent(.... list of params ...)
    {
        TDSE mTDSE = null;
        Folder mFolder = null;
        Component mComponent = null;

        bool flag = false;

        try
        {
            mTDSE = TDSEInitialize();
            mComponent = (Component)mTDSE.GetNewObject(ItemType.ItemTypeComponent, folderID, null);
            mComponent.Schema = (Schema)mTDSE.GetObject(constants.SCHEMA_ID, EnumOpenMode.OpenModeView, null, XMLReadFilter.XMLReadAll);
            mComponent.Title = compTitle;

            ...
            ...
            ...
            ...

            mComponent.Save(true);

            flag = true;
        }
        catch (Exception ex)
        {
            CustomLogger.Error(String.Format("Logged User: {0}  \r\n Error: {1}", GetRemoteUser(), ex.Message));
        }
        return flag;
    }

Thanks in advance.

6
  • Is there anything in the Application, Tridion and Tridion Content Manager event logs? Mar 20, 2012 at 9:11
  • 1
    Can you share more about the context of your code. i.e. is it in a ASP.NET page, a console app etc? Also are you sure you are using TOM.NET rather than TOM with interop (I ask because TOM.NET in Tridion 2009 is read-only, so it seems unlikely that you are saving any components using it)? There are no limitations in Tridion 2009 (I have imported tens of thousands of items using both TOM and TOM.NET) relating to the number of items you can import. Perhaps you can share some of your code detailing exactly when the error is thrown. Mar 20, 2012 at 10:28
  • @user978511: I have updated my question with an application event log. In other two places (Tridion and Tridion Content Manager) doesn't have any sort of errors. Mar 20, 2012 at 11:38
  • @ChrisSummers: I have added my piece of code in the question. Am using Interop dll's on C# for this custom page. Mar 20, 2012 at 11:57
  • 1
    @NunoLinhares - that isn't picky. It's a crucial aspect of this question. Apr 30, 2012 at 13:52

4 Answers 4

2

Sounds like a timeout, most likely in IIS which is hosting your custom page. Are you creating them all in one synchronous request? Because that is indeed likely to time out.

You could instead create them in batches - or make sure your operations are done asynchronously and then polling the status regularly.

The easiest would just be to only create say 10 Components in one request, wait for it to finish, and then create another 10 (perhaps with a nice progress bar? :))

5
  • Can you suggest with some examples? So i can try with that and see. Mar 20, 2012 at 11:59
  • I am pretty sure Peter K has this correct with regard IIS timeouts. You can increase the Server Timeout for your custom page by doing something like "Server.ScriptTimeout = 3600;", but creating batches would be more elegant. This is what we often did in the old 2009 PowerTools. Mar 20, 2012 at 12:03
  • @ChrisSummers: Actually creating batches would be good idea but user can't upload batch by batch that is the problem. So I need to create components in one flow 500 / 600 / 700 or more than that. Mar 20, 2012 at 12:08
  • Then I think the quick and dirty way is to set the timeout in the script. I believe the default is 90 secs in IIS. Alternativley build a Windows Form or Console program which can be executed on the server which is not subject to IIS timeouts. What is the source of data for the import? Mar 20, 2012 at 12:14
  • @ChrisSummers: source is excel sheet Mar 20, 2012 at 12:31
2

How you call TDSE object. I would like to mention here "Marshal.ReleaseComObject" procedure. Without releasing COMs objects can lead to enormous memory leaks. Here is code for component creating:

private Component NewComponent(string componentName, string publicationID, string parentID, string schemaID)
    {
        Publication publication = (Publication)mTdse.GetObject(publicationID, EnumOpenMode.OpenModeView, null, XMLReadFilter.XMLReadContext);
        Folder folder = (Folder)mTdse.GetObject(parentID, EnumOpenMode.OpenModeView, null, XMLReadFilter.XMLReadContext);
        Schema schema = (Schema)mTdse.GetObject(schemaID, EnumOpenMode.OpenModeView, publicationID, XMLReadFilter.XMLReadContext);
        Component component = (Component)mTdse.GetNewObject(ItemType.ItemTypeComponent, folder, publication);
        component.Title = componentName;
        component.Schema = schema;
        return component;
    }

After that please not forget to release mTdse ( in my case it is previously created TDSE object). Disposing "Components" object can be useful also after finish working with them.

0

For large Tridion batch operations I always use a Console Application and run it directly on the server.

Use Console.WriteLine to write to the output window and Console.ReadLine as the last line of code in the app (so the window stays open). I also use Log4Net as the logger.

This is by far the best approach if you have access to a remote session on the server - or can ask an admin to run it for you and give you access to the log folder via a network share.

2
  • In Console Applications using the TOM.NET API is not supported. So you'd either have to use the Core Service (on Tridion 2011 and up) or the good-old TOM (on Tridion 2009 and earlier). Note that the TOM.NET may work fine in custom pages, but since it runs in a different process it may cause problems. Mar 20, 2012 at 17:10
  • Thanks for suggestion. But currently I can't use as a console application. Since there are different users, who needs to access this custom page. Mar 20, 2012 at 17:18
0

As per @chris suggestions and part of immediate fix I have changed my web.config execution time out to 8000 seconds.

<httpRuntime executionTimeout="8000"/>

With this change, custom page is able to handle as of now.

Any more best suggestion, please post it.

1
  • @Chris - why don't you post this as an answer instead of as a comment? Apr 30, 2012 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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