public static void InitializeSecurity()
{
int error = CoInitializeSecurity(
IntPtr.Zero,
-1,
null,
IntPtr.Zero,
RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IMPERSONATE,
IntPtr.Zero,
EOAC_DYNAMIC_CLOAKING,
IntPtr.Zero);
// this call will fail in the debugger if the
// 'Debug | Enable Visual Studio Hosting Process'
// option is checked in the project properties.
if (error != 0)
{
// throw new ExternalException("CoInitializeSecurity: " + GetSystemMessage(error), error);
}
}