I have an InfoPath form that contain a function (In .Net CodeForm- C#).
In the function I'm creaing an object of WebService that get the form's value and enter them into database.
When I run my form as a preview form, It's all work well. But when I publish the form into sharepoint portal and run it I get this Error:
"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(PermissionToken permToken, CodeAccessPermission
demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark&
stackMark)
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 System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri)
at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[]
parameters)
at NonProductReq.NPService.Service1.InsertNPReqMaster(String RequestID, String SuggestedVendor,
String DateWritten, String DateRequest, String Resale, String ConfirmedTo, String ConfirmedDate,
String PayExtra, String DeliverTO, String OriginatedBy, String PhoneNumber)
at NonProductReq.NonProductReq.btnCreate_OnClick(DocActionEvent e)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent
pEvent)"
It looks like a security issue.
Why it's happen and how to fix it?