I am running SQL Server locally only. I am building a project with VS 2017 community. I created a CLR procedure, and uploaded it as an assembly successfully. The class and the method are public. I created a SQL standard proc to call the clr proc with permissions_set = external_access. Trustworthy is on. Alter authorization is set to sa.
All it does is execute a bat file: cmd.exe c:\temp\test.bat
But I'm still getting an error 6522 Security Exception.
When I run the method as a console app, it runs perfect. But in SQL Server, no go.
I'd be very grateful for any advice - this is my first attempt with CLR.
Code:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.IO;
using System.Diagnostics;
using System.Text;
public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void RunTestBat()
    {
        ProcessStartInfo pPStartInfo = new ProcessStartInfo("cmd.exe");
        pPStartInfo.WorkingDirectory = @"C:\Temp";
        pPStartInfo.UseShellExecute = true;
        pPStartInfo.Arguments = string.Format(@" /C test.bat");
        Process p = new Process();
        p.StartInfo = pPStartInfo;        
        p.Start();
        p.WaitForExit();
    }
};
 
    