Application attempted to perform an operation not allowed by the security policyhttp://forums.asp.net/t/1192379.aspx/1?Application+attempted+to+perform+an+operation+not+allowed+by+the+security+policySun, 20 Jan 2008 05:52:57 -050011923792051070http://forums.asp.net/p/1192379/2051070.aspx/1?Application+attempted+to+perform+an+operation+not+allowed+by+the+security+policyApplication attempted to perform an operation not allowed by the security policy <p>Apologies if I've posted this in the wrong forum but I didn't know where else to post...&nbsp;</p> <p>Ok, here's the scenario:</p> <p>&nbsp;I have an application with two buttons, one of which I want to log the user off. The problem is that this runs as a startup program and runs off a network share. The app works fine on my local machine but whenever I try to run it from a network share, I get security privilege errors:</p> <p>&nbsp;Application attempted to perform an operation not allowed by the security policy... Request for the permission of type &quot;System.Security.Permission, mscorlib, Version 2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089</p> <p>Then I can continue or quit. How can I stop this error message box coming up?</p> <p>If I go to the command line of the machine that I'm trying to run the app on and go to the .NET directory and run CasPol.exe -s off, it will then work. How can I get&nbsp; it to work everytime? I have tried:</p> <p>Shell(&quot;CasPol -s off&quot;)</p> <p>&nbsp;<br> The other problem is that the machines I'm running the app on may have different .NET versions installed and in different places...</p> <p><br> Here's my code:</p> <p>&nbsp;</p> <pre class="prettyprint">Private Sub btDisagree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDisagree.Click 'Shell(&quot;CasPol -s off&quot;) Shell(&quot;shutdown -l&quot;)</pre><pre class="prettyprint"> <span class="kwd">End Sub End Class</span> </pre> <p>The strange thing is that I have another app with the identical call (Shell(&quot;shutdown -l&quot;)) and it runs perfectly. There must be something I'm missing. if anyone can help me I'd be very grateful!!!<br> </p> <p>Failing this, can anyone tell me how to log off a user through a windows form without incurring security issues?</p> <p>&nbsp;</p> <p>Thanks in advance,</p> <p><br> &nbsp;</p> <p><br> &nbsp;</p> 2007-12-10T16:47:07-05:002052293http://forums.asp.net/p/1192379/2052293.aspx/1?Re+Application+attempted+to+perform+an+operation+not+allowed+by+the+security+policyRe: Application attempted to perform an operation not allowed by the security policy <p>Does anyone have any ideas?&nbsp;</p> 2007-12-11T07:35:28-05:002054910http://forums.asp.net/p/1192379/2054910.aspx/1?Re+Application+attempted+to+perform+an+operation+not+allowed+by+the+security+policyRe: Application attempted to perform an operation not allowed by the security policy <p></p> <blockquote><span class="icon-blockquote"></span> <h4>freelandera</h4> <p>The problem is that this runs as a startup program and runs off a network share. The app works fine on my local machine but whenever I try to run it from a network share, I get security privilege errors:</p> <p>&nbsp;Application attempted to perform an operation not allowed by the security policy... Request for the permission of type &quot;System.Security.Permission, mscorlib, Version 2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089</p> <p></p> </blockquote> <p></p> <p>Hi</p> <p>What happens in your code is the application attempted to perform an operation (execute external programme) not allowed by the security policy. For testing purposes you can try to add this line in your web.config if host admin doesn't lock the trust level section.</p> <p>&nbsp; &lt;system.web&gt;<br> &nbsp;&nbsp;&nbsp; &lt;trust level=&quot;Full&quot; originUrl=&quot;&quot; /&gt;<br> &nbsp; &lt;/system.web&gt;</p> <p>A more prosaic approach is looking into the call stack and using the custom permission set for security policy.</p> <p>Here you can get more information</p> <p><a href="http://msdn2.microsoft.com/en-us/library/tkscy493(VS.80).aspx">http://msdn2.microsoft.com/en-us/library/tkscy493(VS.80).aspx</a></p> <p>If it's a share host, you probably need to discuss with your hosting provider and get some restrictions on what you can and cannot do. For security reasons, Most share host will restrict execute extrnol programme.</p> 2007-12-12T09:40:22-05:002119409http://forums.asp.net/p/1192379/2119409.aspx/1?Re+Application+attempted+to+perform+an+operation+not+allowed+by+the+security+policyRe: Application attempted to perform an operation not allowed by the security policy <p>I have a related post at <a href="http://forums.asp.net/t/1207364.aspx">http://forums.asp.net/t/1207364.aspx</a>. It's extremely strange that in testing the application, one entry would be accepted and others would not.</p> 2008-01-19T06:32:32-05:002120264http://forums.asp.net/p/1192379/2120264.aspx/1?Re+Application+attempted+to+perform+an+operation+not+allowed+by+the+security+policyRe: Application attempted to perform an operation not allowed by the security policy <p>I seemed to have resolved it by changing the Trust Level to &quot;Full&quot; in web.config:</p> <font color="#0000ff" size="2"> <p>&lt;</font><font color="#800000" size="2">trust</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">level</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">Full</font><font size="2">&quot;</font><font color="#0000ff" size="2">/&gt;</p> </font> <p>It still puzzles me as to why the application would accept one set of input and not another.</p> 2008-01-20T05:52:57-05:00