.Net - interop assemblies taking 15 seconds to load when being referenced in a function

StackOverflow https://stackoverflow.com/questions/279495

  •  07-07-2019
  •  | 
  •  

Question

This is a C# console application. I have a function that does something like this:

static void foo()
{
       Application powerpointApp;
       Presentation presentation = null;

       powerpointApp = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
}

That's all it does. When it is called there is a fifteen second delay before the function gets hit. I added something like this:

static void MyAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs args)
{
       Console.WriteLine(DateTime.Now.ToString() + " ASSEMBLY LOADED: " + args.LoadedAssembly.FullName);
       Console.WriteLine();
}

This gets fired telling me that my interop assemblies have been loaded about 10 milliseconds before my foo function gets hit. What can I do about this? The program needs to call this function (and eventually do something else) once and then exit so I need for these assemblies to be cached or something. Ideas?

Was it helpful?

Solution

It could be the certificate revocation list - the time-out on this is 15 seconds. Is there anything in the event log? Can you check if any network connections are happening during the time-out?

I blogged some details about certificate revocation delay a while ago. Follow the link, I won't cut and paste it here.

OTHER TIPS

15 seconds sounds like a timeout to me. Are you signing your assemblies? We had a problem where the framework wants to check the certificate revocation list when loading, but fails after 15 secs.

HTH

Tim

<runtime>

   <generatePublisherEvidence enabled="false"/>

</runtime>

See here for details

http://msdn.microsoft.com/en-us/library/bb629393.aspx

"We recommend that services use the element to improve startup performance. Using this element can also help avoid delays that can cause a time-out and the cancellation of the service startup."

Just guessing, but it is probably the time for PowerPoint to start up after the interop assemblies have loaded.

If method foo() is not called upon application start and you have some other tasks to do before it is called, you can start a separate thread in the beginning to load the assemblies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top