Guest
2010-06-10T15:58:52Z
I am using the following to send a text message

objIntelliSMS.PrimaryGateway = "https://www.intellisoftware.co.uk"
        objIntelliSMS.BackupGateway = "https://www.intellisoftware2.co.uk"

        objIntelliSMS.ProxyAddress = "**********"
        'HttpWebRequest.DefaultWebProxy.ToString()
  
        objIntelliSMS.ProxyUsername = "***************"
        objIntelliSMS.ProxyPassword = "***********"

        mobNo = mobNo.TrimStart("0")
        mobNo = "44" + mobNo

        objIntelliSMS.Username = "***********"
        objIntelliSMS.Password = "**********"

        Try
            MessageId = objIntelliSMS.SendMsg(mobNo, sms_message, "**********")
            SendTxt = MessageId
        Catch smsExeception As IntelliSMSException
            SendTxt = "SMS Error Type: " + smsExeception.ResultCode.ToString + " " + smsExeception.Message + vbCr + smsExeception.InnerException.ToString
        Catch ex As Exception
            SendTxt = ex.ToString
        End Try

I am getting a the following error:

System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, 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.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) at System.Net.HttpRequestCreator.Create(Uri Uri) at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) at System.Net.WebRequest.Create(Uri requestUri) at IntelliSoftware.Common.HTTPConnection.HTTPRequest(String sMethod, String sUrl, String sContentType, String sFormData) at IntelliSoftware.Common.HTTPConnection.HTTPPost(String sURL, String sPostData, String ContentType) at IntelliSoftware.Internal.SMSGatewayService.MakeHTTPRequest(String sURL, SMSGatewayRequestData objSMSGatewayRequestData, String sReturnCodePrefix, String& sRawResponse, ResultCodes& ResultCode, Exception& InternalException) The action that failed was: Demand The type of the first permission that failed was: System.Net.WebPermission The first permission that failed was: <IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1"> <ConnectAccess> <URI uri="https://www\.intellisoftware2\.co\.uk/smsgateway/default\.aspx"/> </ConnectAccess> </IPermission> The demand was for: <IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1"> <ConnectAccess> <URI uri="https://www\.intellisoftware2\.co\.uk/smsgateway/default\.aspx"/> </ConnectAccess> </IPermission> The granted set of the failing assembly was: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="USERNAME"/> <IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="Y:\Visual Studio 2008\Projects\SMS\bin\" PathDiscovery="Y:\Visual Studio 2008\Projects\SMS\bin\"/> <IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Allowed="AssemblyIsolationByUser" UserQuota="9223372036854775807" Expiry="9223372036854775807" Permanent="True"/> <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ReflectionEmit"/> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Assertion, Execution, BindingRedirects"/> <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> <IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010083B1457F4199018A8D8B8C626704A48401A9932C8A08CBDF5C6F38BE0103EA1D3177C7769D6A342E7DE9D4EABAAB826AF6D2CBCF2DF8CCD02929ABAE81AB71FF9F549047FBC54DEE2DE059DC5F3D2D51600F2A3FAAC71219E18C7C4B633B2F3E7FC1C9347E61173C3515B948C268FE6E8FFA3710FEBE93FD406E769D2E5EB7BA" Name="IntelliSMSDotNet" AssemblyVersion="4.5.0.0"/> <IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Url="file:///y:/Visual Studio 2008/Projects/SMS/bin/IntelliSMSDotNet.DLL"/> <IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Zone="Intranet"/> <IPermission class="System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> <IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" version="1" Level="DefaultPrinting"/> </PermissionSet> The assembly or AppDomain that failed was: IntelliSMSDotNet, Version=4.5.0.0, Culture=neutral, PublicKeyToken=500d2211a5cfb13e The method that caused the failure was: System.String HTTPRequest(System.String, System.String, System.String, System.String) The Zone of the assembly that failed was: Intranet The Url of the assembly that failed was: file:///y:/Visual Studio 2008/Projects/SMS/bin/IntelliSMSDotNet.DLL
Support
2010-06-10T17:14:21Z
We have not heard of this issue before.

Looking around the internet there are plenty of references to this error you have encountered:
Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

It appears to be an issue with the trust level of our IntelliSMSDotNet.DLL assembly. It is probably run with Medium trust level.

A work around is to edit the C:\WINDOWS\Microsoft.NET\Framework\vx.x.xxxx\CONFIG\web_mediumtrust.config file.

Add the following URL to the IPermission node for class="WebPermission":

<IPermission
    class="WebPermission"
    version="1">
        <ConnectAccess>
            <URI uri="$OriginHost$"/>
            <URI uri="http://www\.intellisoftware\.co\.uk/smsgateway/.*"/>
            <URI uri="http://www\.intellisoftware2\.co\.uk/smsgateway/.*"/>
            <URI uri="https://www\.intellisoftware\.co\.uk/smsgateway/.*"/>
            <URI uri="https://www\.intellisoftware2\.co\.uk/smsgateway/.*"/>
        </ConnectAccess>
</IPermission>

After the code change you will need to restart you IIS (or alternative reboot your machine)
Guest
2010-06-11T09:33:30Z
I have made the change to the web_mediumtrust.config in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG (which is the only web_mediumtrust.config file i could find) and I am still getting the same error.
Guest
2010-06-11T11:51:27Z
http://support.microsoft.com/?id=320268 

Seems that .NET relies on the full trust permissions that the My Computer one has.

So I have moved the application to the C: and its working fine.

Thank you for you speedy reply.
Users browsing this topic