cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Using LibCurlNet in a Windows Service

From: Jeff Phillips <jeff_at_jeffp.net>
Date: Tue, 1 Mar 2005 07:31:53 -0800 (PST)

Hello Anthony,

What version of libcurl.NET are you using? If it's a
version prior to 1.3, perhaps the problem is some kind
of security issue relating to the fact that the
earlier versions are signed assemblies. If not,
perhaps we can take the issue off-line, hopefully
resolve it, and then post an answer to this board.

Take care,
Jeff

--- Anthony Desouza <Anthony_at_dxsolutions.co.uk> wrote:

> 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");
>
>
>
>
Received on 2005-03-01