Here is my minimal example producing the problem:
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Excel = Microsoft.Office.Interop.Excel;
class Program
{
static void Main(string[] args)
{
Task.Run(() =>
{
Excel.Application app = new Excel.Application();
if (app != null)
{
app.Quit();
Marshal.FinalReleaseComObject(app);
app = null;
}
});
}
}
This results in the following exception:
The last part in Japanese says the "EventSetInformation" of DLL advapi32.dll entry point cannot be found
.
I'm having difficulty understanding what is going on. Basically why is this exception being thrown and what it is trying to tell me?
The exception in my example was produced with VS 2013 on Windows 7.
In this case, the call to EventSetInformation
could not be resolved as the function could not be found in advapi32.dll
.
Then, I tested the same code with Visual Studio 2015 CTP and it ran to completion without any exceptions. This led me to believe it was a version conflict.
Also, according to here and msdn, EventSetInformation
was added to advapi32.dll in Windows 8. This is why it could not be found when I ran the code with VS 2013. Therefore, to run my code snippet, I needed the newer version of advapi32.dll which is included with later Visual Studio versions (or Windows 8).
UPDATE
According to https://github.com/dotnet/coreclr/issues/974
Note that the OS group has assured us that Win7 will be patched to
include this API soon (within months), so that even the exception will
not happen at that point
So, most likely advapi32.dll on Windows 7 will be updated to include EventSetInformation
some time in the future.