comp.lang.ada
 help / color / mirror / Atom feed
From: "Hakan" <yilmazhakan72@gmail.com>
Subject: Ada to Interfacing C# (Urgent)
Date: 24 Mar 2006 10:30:08 -0800
Date: 2006-03-24T10:30:08-08:00	[thread overview]
Message-ID: <1143225008.097384.33200@t31g2000cwb.googlegroups.com> (raw)

I have been using a library written in Ada 95 for a while. (source code
available in Ada 95 and is written by someone else)
I have built an ADA DLL by using GNAT compiler for  Windows using this
library and
written some wrapper code in .Net 2003 with C#  which calls services
from the ADA DLL.
My problem is I get and "Object Reference Not set to an istance.."
error (or Access Violation error) in the Visual Studio 2003 Environment
when calling the
"Create_Exception_Ptr(ref ExcpWrp)" service given below:

The C# Code where the problem is:
[DllImport(("Mydll.dll"), CallingConvention=CallingConvention.Cdecl)]
internal static extern void Create_Exception_Ptr(ref IntPtr ExcpWrp);
public IntPtr CreatePtr()
{
   IntPtr ExcpWrp = IntPtr.Zero;
   try
{
    Create_Exception_Ptr(ref ExcpWrp);
}
catch (System.Exception ex)
{
string msg = ex.Message;
}
return ExcpWrp;
}
The corresponding Ada code is:

---spec file--
with Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
.........
package C renames Interfaces.C;
type Exception_Ptr is access all chars_ptr;
pragma Controlled(Exception_Ptr);
procedure Create_Exception_Ptr(ExceptionPtr : in out Exception_Ptr);
pragma Export (C, Create_Exception_Ptr,"Create_Exception_Ptr");

-- body file--
....
procedure Create_Exception_Ptr(ExceptionPtr : in out Exception_Ptr) is
begin
  ExceptionPtr := new Chars_Ptr;
  ExceptionPtr.all:=Null_Ptr;
  ExceptionPtr.all:=New_Char_Array(C.To_C("NULL"));
end Create_Exception_Ptr;

 Actually, the problem arised when I start using the new version of my
Ada software Library (There was no problem with the old version. The
same code in C# and Ada works fine) The new Ada software library is big
in size and has a lot of Storage Pool allocation. Not  much dynamic
memory allocation. I tried to debug the Ada DLL, but I realized the
debugger does not go inside the function at runtime and an error
message ....SEGMENTATION FAULT....secondary_stack......is given.

Does anyone has an idea to overcome this problem? Please help for this,
 I have a time constraint. (I have used both Gnat 3.15p and Gnat
5.03a1, but found no solution)
 
Thanks a lot.
 
Best regards, Hakan.




             reply	other threads:[~2006-03-24 18:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-24 18:30 Hakan [this message]
2006-03-25  0:32 ` Ada to Interfacing C# (Urgent) Jeffrey R. Carter
2006-03-25  8:09   ` Martin Krischik
2006-03-26 17:44     ` Hakan
2006-03-25  8:49   ` Hakan
2006-03-26  0:31     ` Jeffrey R. Carter
2006-03-26  9:12       ` Hakan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox