Forum Visual Studio

Debugging an application that require administrative privileges

ClodoClodo ITMember ✭✭

I write a software that need administrative privileges (it's a system utility).
I run my build from terminal with 'sudo'.
The software itself detect if is launched with elevated privileges. If not, restart itself with 'AuthorizationExecuteWithPrivileges'.

But... how i can debug it from within Xamarin Studio? How to launch a debug session with sudo? Thanks for any feedback.


  • mhutchmhutch USMember, Xamarin Team Xamurai

    Not really supported, but in theory you could launch your app manually and use the custom soft debugger to connect to it.

  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    Another option might be to run Xamarin Studio under the Administrator account and launch the app in the debugger that way.

  • ClodoClodo ITMember ✭✭

    "run Xamarin Studio under the Administrator account" don't work.
    I try "cd /Applications/Xamarin" and a "sudo ./XamarinStudio". It's running under another users because XS settings & recents files are different. But seem that debugging it's always start without administrative privileges.

    I will study the remote debugging. But an option in Xamarin Studio for that maybe quickly added by Xamarin Team and, for me, is an important improvement. Thanks.

  • AlexanderConnAlexanderConn USMember
    edited January 2016

    Actually you can this is working for me:

    var defaults = Security.AuthorizationFlags.Defaults;
    using (var auth = Security.Authorization.Create(defaults))
    var args = new[]{"-c", "\"\"" + CommandtoRun + " " + CommandArguments + "\"\""};
    auth.ExecuteWithPrivileges("/bin/sh", defaults, args);

  • uukuuk JPMember

    I have a same problem.It was solved in the following way.

    If you can enable the root user in macOS.You run Xamarin Studio as root user, then debug the app.
    The app starts with root privileges, it will not be restarted.

Sign In or Register to comment.