I have a C# method that accesses the Excel API that's defined in the office.dll
that gets installed in the GAC with MS office.
This method fails with a FileNotFoundException
when being called on a computer that doesn't have MS office installed even if I have a statement that avoids calling the api.
ie. This code throws an exception on an office-free computer, I'm guessing during type loading.
void TestStuff()
{
try
{
if (machineHasNoExcel) return;
Excel.Application.Stuff();
} catch() { }
}
How can I avoid that exception? Can I make the typeloader not throw and trust that the code is not going to call the missing API? I really would prefer to avoid late binding.