Hi,
I'm developing a Windows Control Library to use as Smart Client in a
ASP.NET application and one of the tasks of my custom control is call a
WebService. So, when i try to call the WebService using my control
through the IE, i get this exception:
System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.CredentialCache.get_DefaultCredentials()
at
System.Web.Services.Protocols.WebClientProtocol.set_UseDefaultCredentials(Boolean
value)
at
com.Enterprise.Impressao.webCaixa.Caixa.set_UseDefaultCredentials(Boolean
value)
at com.Enterprise.Impressao.webCaixa.Caixa..ctor()
at com.Enterprise.Impressao.PDV.enviaReducao(String[]
memoriaFiscal, Boolean isReducaoZ)
at com.Enterprise.Impressao.PDV.fecharCaixa()
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.EnvironmentPermission
and i call my webService at enviaReducao() method. I've trusted my
assembly as FullTrust too.
What should i do?
thanks in advance.
Jas - 20 Feb 2006 22:09 GMT
Jose,
Are you sure the smart client is actually granted full permission by the
runtime? It looks like its not being granted permission to read some
environment variable. Use the wizard to "evaulate assembly".
jas
> Hi,
>
[quoted text clipped - 32 lines]
>
> thanks in advance.
Nicole Calinoiu - 21 Feb 2006 13:30 GMT
How have you granted unrestricted permissions (full trust) to your assembly?
Also, was this done on the web server or on the client machine where the web
page is being viewed?
> Hi,
>
[quoted text clipped - 32 lines]
>
> thanks in advance.
José Nunes - 23 Feb 2006 15:01 GMT
Well, i solved it just putting the following lines above my webservice
method caller...:
[WebPermission(SecurityAction.Assert, Unrestricted = true)]
[EnvironmentPermission(SecurityAction.Assert, Unrestricted = true)]
And i trusted my assembly in the client machine using a Strong name key
generated by the sn.exe. In the .net framework configuration i created
a new codegroup called "MyComponent", using the membership condiction
type as Strong Name and the Permission Set equal Full trust.