delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/11/01/14:10:09

X-Spam-Check-By: sourceware.org
Message-ID: <4548FF03.50403@cygwin.com>
Date: Wed, 01 Nov 2006 15:09:39 -0500
From: "Larry Hall (Cygwin)" <reply-to-list-only-lh AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060916 Fedora/1.5.0.7-1.fc4.remi Thunderbird/1.5.0.7 Mnenhy/0.7.4.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Possible to use pinvoke to call DLL built with cygwin
References: <6bd5d4070611010944m5567b5a1r4bd10d7a55327c2a AT mail DOT gmail DOT com>
In-Reply-To: <6bd5d4070611010944m5567b5a1r4bd10d7a55327c2a@mail.gmail.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Sammy Yu wrote:
> Hi guys,
>    I'm trying to port an application onto Windows that was originally
> developed for UNIX using rpc, pthreads, and AF_UNIX sockets.  I have
> used cygwin to compile this application successfully.  One of the
> components built is a DLL which I want to invoke from a C Sharp
> application.  However, the application crashes whenever I call this
> DLL via pinvoke in C Sharp.
> 
> 
> ************** Exception Text **************
> System.DllNotFoundException: Unable to load DLL 'perm.dll': Invalid
> access to memory location. (Exception from HRESULT: 0x800703E6)
>    at WinPcapRedirectorUI.Perm.meme ()
>    at WinPcapRedirectorUI.MainForm.statisticsButton_Click(Object
> sender, EventArgs e) in
> C:\eclipse\workspace\winperm\WinPcapRedirectorUI\MainForm.cs:line 74
>    at System.Windows.Forms.Control.OnClick (EventArgs e)
>    at System.Windows.Forms.Button.OnClick(EventArgs e)
>    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
>    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> button, Int32 clicks)
> 
> 
> I verified that the cygwin*.dll are in the path.   I made a strip down
> version of a dll, it exhibited the same behavior.  Next, I compiled
> the
> library with -mno-cygwin flag which surprisingly worked.  I suspect
> that cygwin1.dll does not work with pinvoke.  Can anybody confirm this
> is true?  I prefer not to have to port the native application to
> Visual C or mingw32 as there are a lot of rpc and AF_UNIX sockets.
> Are there any other alternatives?  Thanks in advance for your help!


You need to initialize the DLL.  Loading the Cygwin DLL from a non-Cygwin
app doesn't initialize it automatically.  Only Cygwin apps do that.  Off
the top of my head, I don't recall the details but this has been discussed
before in the email archives, if you want to poke around a bit for the
procedure.


-- 
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019