Skip to content
⌘ NSIS Forum Archive

.Net dll when called using CLR::Call giving exception

5 posts

DivyaArun#

.Net dll when called using CLR::Call giving exception

Hi,

I have a .Net library which checks if a WCF service is up and running. Below is the function I have used.

public string VerifySiteExists(string wcfurl)
{
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(wcfurl);
httpReq.AllowAutoRedirect = false;
HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse();
if (httpRes.StatusCode != HttpStatusCode.OK)
result = "OK";
httpRes.Close();

I have called the same in NISSI using CLR::Call
CLR::Call /NOUNLOAD "TestService.dll" "TestService.MyClass" "VerifySiteExists" 1 "https://axx.xx.com/xx/yyy.svc"

But it gives me the error- "Exception has been thrown by target invocation. I have noticed that it is because of the .Net class HttpWebRequest. If I comment those functions and return a simple "Hello World" string, it works fine.

Kindly advice.

Thanks
DivyaArun#
Originally Posted by Anders View Post
Have you tried debugging? We need to know if the crash is in your code or the CLR plug-in...
Yes, I had confirmed that .Net code is working one. I presume the issue is related to the reference to System.Net.Http.dll.