vb スクリプトを実行する必要がある Web アプリケーション (VS2012 Web を使用) を公開しようとしています。
そのスクリプトは現在、おそらく権限が不足しているため、正しく実行されません。現在、ユーザーとして実行し、資格情報を提供しようとしています。私が提供しなければならないパスワードはSystem.Security.SecureString
、char* を作成する必要がある にある必要があります。
アプリをデバッグで実行すると、すべて正常に動作し、期待どおりに動作します。しかし、アプリをサーバーに公開するときが来ると、次のように表示されます。
1>C:\SVN\...\Default.aspx.cs(108,21,108,27): error CS0227: Unsafe code may only appear if compiling with /unsafe
プロジェクトのプロパティで安全でないコードを許可しましたが、公開時ではなくデバッグ時に VS がそのプロパティを参照する理由がわかりません。
パブリッシュを押すと、エラー リストに CS0227 エラーが表示されますが、1 秒間しか表示されず、その後消えます...ビルドが失敗するのに十分なようです。
問題が何であるかについてのアイデアはありますか?
これが私のコードです:
Process proc = new Process();
ProcessStartInfo psi = new ProcessStartInfo("C:\\Windows\\System32\\cscript.exe", "\"" + scriptPath + "\" " + args);
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.CreateNoWindow = true;
psi.Domain = "MyDomain";
psi.UserName = "MyUsername";
System.Security.SecureString hashPwd;
unsafe
{
// Instantiate a new secure string.
fixed (char* pChars = pwd)
{
hashPwd = new System.Security.SecureString(pChars, pwd.Length);
}
}
psi.Password = hashPwd;
//Set the process' start info
proc.StartInfo = psi;
//We start the script.
proc.Start();