Hi,
I am trying to use LIBCURLNET (thank you Jeff Phillips) in a
C# Windows Service Project but am experiencing difficulty.
Everything builds and installs great, but when I try to access
it from a Windows Service I get an exception fired “Unable to load DLL (libcurl.dll)”
logged in an event log, so my CURL operation never takes place. I am perplexed,
because the same code works fine from a Windows application
I have set up a reference to libcurlnet.dll in the service
project and made sure that libcurl.dll is in the service install directory and
even stuck it in the windows/system32 directory.
I have also set my path to include a reference to
/libcurlnet/bin/
I expected Libcurlnet.dll to work the same whether in a
service project or application project and I appear to be referencing it the
same way.
I am a very new .NET developer. Is there any thing stupid I might
be omitting to do when building my Window Service, to make sure it can load
libcurl.dll?
Many thanks,
Anthony :)
Here is an example of my slightly modified EasyGet based on Jeff
Phillip’s sample.
using SeasideResearch;
using SeasideResearch.LibCurlNet;
class EasyGet
{
public static string strGetData;
public static string strErrorMessage;
public EasyGet()
{
EasyGet.strErrorMessage
= "";
}
public EasyGet(string strURL)
{
try
{
EasyGet.strErrorMessage
= "";
EasyGet.strGetData
= "";
Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
Easy
oCurlOP = new Easy();
Easy.WriteFunction
wf = new
Easy.WriteFunction(OnWriteData);
oCurlOP.SetOpt(CURLoption.CURLOPT_URL,
strURL);
oCurlOP.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION,
wf);
oCurlOP.Perform();
oCurlOP.Cleanup();
Curl.GlobalCleanup();
}
catch(Exception ex)
{
EasyGet.strErrorMessage
= ex.Message;
}
}
public string GetTransferData()
{
return EasyGet.strGetData;
}
public string GetTransferError()
{
return
EasyGet.strErrorMessage;
}
public static Int32 OnWriteData(Byte[] buf, Int32
size, Int32 nmemb, Object extraData)
{
EasyGet.strGetData
= System.Text.Encoding.UTF8.GetString(buf);
return size * nmemb;
}
}
This is how I use this object, to query a PHP file that
returns database results.
EasyGet oCurlOp = new
EasyGet(PATH_IDMS + "getMachinePingData.php");