This problem may occur when the custom assemblies that are referenced in project do not have sufficient permissions.
To grant the required permissions to a custom assembly, follow these steps:
1. Assert permissions in your custom assembly.
2. Make the custom assembly available to project.
3. Reference the custom assembly in your project.
4. Modify the code access security settings for your custom assembly.
Assert permissions in your custom assembly To acquire the required permissions to run the code in your custom assembly, you must assert the required permissions in your custom assembly code.
For example, if you access data in Microsoft SQL Server tables by using the "System.Data.SQLClient" namespace in your custom assembly, you must add the following code to your custom assembly before you use the "System.Data.SQLClient"
namespace:
System.Data.SqlClient.SqlClientPermission pSql = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted); pSql.Assert();
If you access a file in your custom assembly, you must add the following code to your custom assembly before you access the file:
FileIOPermission filePerm = new FileIOPermission(FileIOPermissionAccess.Read, "C:\TestFile"); filePerm.Assert();
Similarly, if you access a Web service in your custom assembly, you must add code that is similar to the following to assert the Web permissions:
System.Text.RegularExpressions.Regex urlRegEx = new System.Text.RegularExpressions.Regex(@"http://www\.webcontinuum\.net/.*");
System.Net.WebPermission p = new System.Net.WebPermission(NetworkAccess.Connect,urlRegEx);
JohnySmithy2...
Participant
825 Points
159 Posts
Re: Request for the permission of type 'System.Net.WebPermission
Aug 12, 2006 03:59 AM|LINK
This problem may occur when the custom assemblies that are referenced in project do not have sufficient permissions.
To grant the required permissions to a custom assembly, follow these steps:
1. Assert permissions in your custom assembly.
2. Make the custom assembly available to project.
3. Reference the custom assembly in your project.
4. Modify the code access security settings for your custom assembly.
Assert permissions in your custom assembly
To acquire the required permissions to run the code in your custom assembly, you must assert the required permissions in your custom assembly code.
For example, if you access data in Microsoft SQL Server tables by using the "System.Data.SQLClient" namespace in your custom assembly, you must add the following code to your custom assembly before you use the "System.Data.SQLClient" namespace:
System.Data.SqlClient.SqlClientPermission pSql = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
pSql.Assert();
If you access a file in your custom assembly, you must add the following code to your custom assembly before you access the file:
FileIOPermission filePerm = new FileIOPermission(FileIOPermissionAccess.Read, "C:\TestFile");
filePerm.Assert();
Similarly, if you access a Web service in your custom assembly, you must add code that is similar to the following to assert the Web permissions:
System.Text.RegularExpressions.Regex urlRegEx = new System.Text.RegularExpressions.Regex(@"http://www\.webcontinuum\.net/.*");
System.Net.WebPermission p = new System.Net.WebPermission(NetworkAccess.Connect,urlRegEx);
p.Assert();
For more information about asserting permissions in your custom assembly, visit the following MSDN Web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_prog_rdl_0so6.asp
Smith
http://spaces.msn.com/johnysmith