1

Currently I am calling ADMT COM object in C# with the following code.

            Type admtMigration = Type.GetTypeFromProgID("ADMT.Migration",true);
            dynamic admt = Activator.CreateInstance(admtMigration);
            IList<MethodInfo> props = new List<MethodInfo>(admtMigration.GetMethods());

However It also requires elevated privileges. Running VS 2017 in administrator mode I can debug the application, but after deploying the DLL, the Code throws error.

I have seen this question, and I can't user Application Manifest File for permission,

also I can't decorate my class with

[PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")]

since it is throwing error at application runtime.

Any Idea how can I run COM object with elevated privileges in C#.

KanisXXX
  • 757
  • 7
  • 19
  • The app that uses this COM object must run elevated. Why this app can't user a manifest is quite unclear. You can create a shortcut to the app on the desktop and tick its "Run as administrator" checkbox in the Advanced properties. – Hans Passant May 08 '19 at 13:57
  • @HansPassant this is class library which will act as connector for the main application, the main application itself will not run elevated (This is not my choice). I am searching anything by which I can run only my class library project with elevated privilege, I don't even know if this is possible or not. – KanisXXX May 08 '19 at 18:12

0 Answers0