I am using .net Framework 4.5. The following piece of code works fine when i run through Visual Studio on my machine. It also works fine when deployed onto my local IIS 7.5(Windows 7). However on deploying the same to one of the dev boxes having the similar .net 4.5 framework (Windows 2008 Server R2) an exception is thrown. Below are the details of the exception and the line where it is thrown. To be brief i have used both webclient and httpwebrequest classes to post the request however the exception seems to be consistent. Any post operation to any website fails on deployed code
Code snippet
WebClient wc = new WebClient();
string postbody = "test";
string response="";
try
{
response = Encoding.ASCII.GetString(wc.UploadData("http://internalservice/abc", Encoding.ASCII.GetBytes(postbody)));
//EXCEPTION THROWN ON wc.UploadData
}
EXception Details:-
Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
Stack Trace:
[FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)] System.Net.HttpWebRequest.GetResponse() +0 System.Net.WebClient.GetWebResponse(WebRequest request) +25 System.Net.WebClient.DownloadBits(WebRequest request, Stream writeStream, CompletionDelegate completionDelegate, AsyncOperation asyncOp) +245 System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) +247 [WebException: An exception occurred during a WebClient request.] System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) +490 System.Net.WebClient.UploadData(Uri address, String method, Byte[] data) +252 OdataDemo.Controllers.CaseSearchController.MakeWamSSoCall(XElement xconfig) +467 |