Note that there are some explanatory texts on larger screens.

plurals
  1. POPublish web application with unsafe code
    primarykey
    data
    text
    <p>I'm trying to publish a web application (with VS2012 Web) in which I need to run a vb script.</p> <p>That script currently doesn't run correctly probably because of the lack of permissions. I am currently trying to run it as a user and supply some credentials. The password I have to provide must be in a <code>System.Security.SecureString</code> which needs a char* to be created.</p> <p>When I run my app in debug everything works fine and as expected. But when comes the time to publish the app to the server, it says :</p> <p><code>1&gt;C:\SVN\...\Default.aspx.cs(108,21,108,27): error CS0227: Unsafe code may only appear if compiling with /unsafe</code></p> <p>I have allowed for unsafe code in the project properties, but I don't know why VS sees that property when debugging and not when publishing.</p> <p>When I hit publish, I see the CS0227 error in the error list but it stays for only 1 second, then it disappears... It seems like that second is enough to make the build fail.</p> <p>Any ideas as to what the problem is?</p> <p>Here is my code :</p> <pre><code>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(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload