I have a C-library to access a Tivoli LDAP directory. Thanks to this
newsgroup I managed to find the correct DllImport (thanks everybody!),
which is:
[DllImport("SIT_UML.dll", EntryPoint="SIT_Registry_Initialise")]public
static extern int InitializeRegistry(ref UIntPtr
LDAPSession,[MarshalAs(UnmanagedType.LPStr)]string
HostPort,[MarshalAs(UnmanagedType.LPStr)]string
AdminUserID,[MarshalAs(UnmanagedType.LPStr)]string AdminPassword);
The LDAPSession is created in my call and I can see that the variable
has a value. In the LDAP browser I can also see a connection is
created, however when I try to pass this to a call as a ref argument
I get an error stating "Object reference not set to an instance of an
object."
The signature in the C-lib is:
[DllImport("SIT_UML.dll", EntryPoint="SIT_TAM_User_Create")]public
static extern int CreateUser(ref UIntPtr LDAPSession,string
TAMID,string UserID,string UserPassword,int Complete);
which I call via
CreateUser(ref LDAPSession,"user","userDN","123",1);
It seems as if the memory block is created but does not contain the
right information? Do I have to cast?
Thanks for helping me out! 1 3113
Francois,
I don't think a cast is necessary. This might be a foolish question,
but what is the value of the LDAPSession that you are passing. If it is
zero, then this is the cause. Otherwise, there is something in the
structure/interface/class that is represented by LDAPSession that might be
zero which is raising the error and bubbling up.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com
"Francois Vanderseypen" <ne***********@hotmail.com> wrote in message
news:40*************************@posting.google.co m... I have a C-library to access a Tivoli LDAP directory. Thanks to this newsgroup I managed to find the correct DllImport (thanks everybody!), which is:
[DllImport("SIT_UML.dll", EntryPoint="SIT_Registry_Initialise")]public static extern int InitializeRegistry(ref UIntPtr LDAPSession,[MarshalAs(UnmanagedType.LPStr)]string HostPort,[MarshalAs(UnmanagedType.LPStr)]string AdminUserID,[MarshalAs(UnmanagedType.LPStr)]string AdminPassword);
The LDAPSession is created in my call and I can see that the variable has a value. In the LDAP browser I can also see a connection is created, however when I try to pass this to a call as a ref argument I get an error stating "Object reference not set to an instance of an object."
The signature in the C-lib is:
[DllImport("SIT_UML.dll", EntryPoint="SIT_TAM_User_Create")]public static extern int CreateUser(ref UIntPtr LDAPSession,string TAMID,string UserID,string UserPassword,int Complete);
which I call via
CreateUser(ref LDAPSession,"user","userDN","123",1);
It seems as if the memory block is created but does not contain the right information? Do I have to cast?
Thanks for helping me out! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andre |
last post by:
if I have an unsafe method that takes in two arrays, performs some
operations and returns; I know that the garbage collector will not
collect objects allocated inside the unsafe method. However, if...
|
by: |
last post by:
Wel, I am rebuilding the VC# 2002 project that I have deployment problems
with the 2003 version, hoping this solves the problems, but now I encounter
this wierd bug???
If I have the project, and...
|
by: Jon Milner |
last post by:
How do I declare that my code is unsafe? Sorry the help
files at my University have not been installed!
|
by: Manish Soni |
last post by:
I am loading an assembly using reflection.
Then I get all the methods in all types.
I want to check whether a method is "unsafe".
The MethodInfo class does not seem to provide this information.
...
|
by: Bradley1234 |
last post by:
Sorry if this is obvious, but Ill ask...
Is there a new way of using pointer operations in C# ?
Ive got a Deitel book on C# that neither mentions the word "pointer" nor
"unsafe" in the index....
|
by: Z |
last post by:
Hello,
In my C# program I have a function that uses pointers. Is there a way to
tell the compiler to compile only this function with the unsafe switch and
compile the remaining project as safe...
|
by: Jerome |
last post by:
Hi all,
I *have* to use unsafe code, but I have a questions : it seems I can't use
delete to free something like : int * myarray = new int.
What should I do if I wanna create/delte/resize such...
|
by: rockdale |
last post by:
Hi, all
Could somebody tells me where can I set "Allow unsafe code" in visual
studio 2005. I could not find any Project Properties|Configuration
Properties in my website solution.
Mine appl...
|
by: Daniel Knöpfel |
last post by:
Hi all
I need to adapt an Msbuild script to compile a visual studio 2005 solution
(including several projects and a website). The application is written in C#
and using .NET 2.0. Due to late...
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
I have two piece of unsafe code. In the first one I'm getting the byte*
pointer of a Bitmap data, and the second one in inside a loop that uses that
byte* pointer to set the data in the Bitmap.
...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |