Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am getting a problem in executing the assembly in app domain

ClassLibrary1 is the assembly and i contains the only one method TestMethod()

In this Testmethod will access the website "www.google.com"

if i call like this its Working fine, but i need to call this through the appdomain.
ClassLibrary1.Class1.TestMethod();

my sample code is:
object[] hEvidence = {new Zone (System.Security.SecurityZone.Internet) };
     Evidence AppEvidence = new Evidence(hEvidence, null);
     AppDomain d = AppDomain.CreateDomain("ClassLibrary1domain");
     d.ExecuteAssemblyByName("ClassLibrary1", AppEvidence);
     AppDomain.Unload(d);


Here i am creating the appdomian with only the privileges access to the Internet
i am getting the Error
Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.


What it is the problem, where i am going wrong.
Posted
Updated 14-Jul-11 22:09pm
v2

1 solution

Did you read the error message? It is quite clear what the problem is, something in your secondary assembly is requesting the UIPermission privilege and it isn't allowed to do it.

WebRequest only requires the WebPermission (according to its documentation), so I guess you are doing something else you haven't told us. For example Console.WriteLine requires UIPermission, as does MessageBox.Show.
 
Share this answer
 
Comments
V V S GANGA SUJAN 16-Jul-11 1:15am    
namespace ClassLibrary1
{
public class Class1
{
public static void TestMethod()
{
ProcessStartInfo sInfo = new ProcessStartInfo("www.google.com");
Process.Start(sInfo);
}
}
}
this thing i am doing in the ClassLibrary1
BobJanova 16-Jul-11 7:19am    
You should really read the documentation. Process.Start can't be used from partially trusted code (which makes sense since what you start isn't in the sandbox and could do anything).

I don't know what you're actually trying to do here. Why start a new AppDomain to launch a browser? You can do that from the main AppDomain.
V V S GANGA SUJAN 16-Jul-11 1:22am    
so how can call this testmethod using the appdomain
please give me some information

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