Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While changing the .net frame work from 3.5 to 4.0 on a project the System.Net.WebPermission object is now throwing exceptions. It appears to happen on the Assert() method. I pasted all the usuals below. When it's recompiled in 3.5 it works as usual.
I can not find any documentation in the 4.0 library on MSDN, has it moved, could the program be missing a reference when compiled with 4.0?


WebPermission myWebPermission =
new WebPermission(System.Security.Permissions.PermissionState.Unrestricted);

myWebPermission.Demand();
myWebPermission.Assert();

ex message
Cannot perform CAS Asserts in Security Transparent methods

- Current
'(myWebPermission.ConnectList).Current'
threw an exception of type 'System.InvalidOperationException'
object {System.InvalidOperationException}

"Enumeration has not started. Call MoveNext."
Posted
Comments
MainFrameMan_ALIVE_AND_WELL$$ 23-Oct-13 11:12am    
maybe a little more information: this is a call from a desktop application. It is doing what they used to call 'screen scraping', go figure. It logs on the the website and removes all the html tags/characters. Parses out the specifice data between the tags and then displays it. Don't ask me why, I won't be able to explain to you the misery; I guess there is no web service available. I went and read the article in the answer, thanks, I have no idea what this means, I don't do Web stuff. I do understand what the permissions is all about, but what changed with using the different frameworks?

1 solution

This article:
.NET 4 Security - Transparent vs Critical: How to use AppDomain.SetData on a Medium Trusted App?[^]
enlights new security aspects with .NET & ASP.NET 4 security implementation.

You may run your IIS site in a restricted security mode, which prevents you from using the System.Security.Permissions.PermissionState.Unrestricted that you want to.

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900