views:

296

answers:

5

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?

A: 

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

kenny
It launches instantly after the assemblies are loaded. The function doesn't even get hit until they get loaded.
Jon
try monitor with your taskmanager, so you call that function, if ppowerpoint.exe is loaded at that point, it could be delayed due to that
faulty
A: 

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.

Sunny
+3  A: 

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

Tim Bailey
+4  A: 

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.

Anthony
This was a very good suggestion. I was noticing a connection that was timing out when the assembly was loading.
Jon
A: 
<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."

Anonymous Type