.Net - interop assemblies taking 15 seconds to load when being referenced in a function
- by Jon
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?