Hi, I'm using VS2005, .net 2 and C# for windows application. I need to
convert a IntPtr to a byte[] to be able to add a meetingBlob data to the
meeting class object in Active Directory schema. I get a "unspecified error"
if I tried to add the data before converting to a byte[] in
"deNewContextObject.Properties["meetingBlob"].Add((object)blob.pData);".
public struct Blob
{
public IntPtr pData;
public int nLength;
public int nSize;
}
int nBytes = Marshal.SizeOf(typeof(CUnityDS.Blob));
IntPtr ptr = Marshal.AllocHGlobal(nBytes);
// create an instance of the Blob structure
CUnityDS.Blob blob = new CUnityDS.Blob();
// copy and pin the structure to that location
Marshal.StructureToPtr(blob, ptr, true);
// Pass it by reference
// OK, now it's time to "reconsitute" the structure
blob = (CUnityDS.Blob)Marshal.PtrToStructure(ptr,
typeof(CUnityDS.Blob));
CUnityDS.DE_ERRORS errcode = CUnityDS.DE_ERRORS.DE_MEMORY_ALLOCATION_FAILURE;
//EncodeAsnUser is a C unmanaged code that puts data from userContextData
struct to IntPtr
errcode = CUnityDS.LibWrap.EncodeAsnUser(ref blob, userContextData);
//Getting unspeficied error with the following line becuase it needs a
byte[] and not IntPtr
deNewContextObject.Properties["meetingBlob"].Add((object)blob.pData);
--
Thanks. 6 4361
System.Runtime.InteropServices.Marshal.Copy(IntPtr source, byte[]
destination, int start, int length)
"Pucca" <Pu***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
Hi, I'm using VS2005, .net 2 and C# for windows application. I need to
convert a IntPtr to a byte[] to be able to add a meetingBlob data to the
meeting class object in Active Directory schema. I get a "unspecified
error"
if I tried to add the data before converting to a byte[] in
"deNewContextObject.Properties["meetingBlob"].Add((object)blob.pData);".
public struct Blob
{
public IntPtr pData;
public int nLength;
public int nSize;
}
int nBytes = Marshal.SizeOf(typeof(CUnityDS.Blob));
IntPtr ptr = Marshal.AllocHGlobal(nBytes);
// create an instance of the Blob structure
CUnityDS.Blob blob = new CUnityDS.Blob();
// copy and pin the structure to that location
Marshal.StructureToPtr(blob, ptr, true);
// Pass it by reference
// OK, now it's time to "reconsitute" the structure
blob = (CUnityDS.Blob)Marshal.PtrToStructure(ptr,
typeof(CUnityDS.Blob));
CUnityDS.DE_ERRORS errcode =
CUnityDS.DE_ERRORS.DE_MEMORY_ALLOCATION_FAILURE;
//EncodeAsnUser is a C unmanaged code that puts data from userContextData
struct to IntPtr
errcode = CUnityDS.LibWrap.EncodeAsnUser(ref blob, userContextData);
//Getting unspeficied error with the following line becuase it needs a
byte[] and not IntPtr
deNewContextObject.Properties["meetingBlob"].Add((object)blob.pData);
--
Thanks.
Thank yuou Lit. The blob is returned to me but the length is not set. How
can I get the length of the IntPrt for the parameter? Thank you.
--
Thanks.
"Lit" wrote:
>
System.Runtime.InteropServices.Marshal.Copy(IntPtr source, byte[]
destination, int start, int length)
"Pucca" <Pu***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
Hi, I'm using VS2005, .net 2 and C# for windows application. I need to
convert a IntPtr to a byte[] to be able to add a meetingBlob data to the
meeting class object in Active Directory schema. I get a "unspecified
error"
if I tried to add the data before converting to a byte[] in
"deNewContextObject.Properties["meetingBlob"].Add((object)blob.pData);".
public struct Blob
{
public IntPtr pData;
public int nLength;
public int nSize;
}
int nBytes = Marshal.SizeOf(typeof(CUnityDS.Blob));
IntPtr ptr = Marshal.AllocHGlobal(nBytes);
// create an instance of the Blob structure
CUnityDS.Blob blob = new CUnityDS.Blob();
// copy and pin the structure to that location
Marshal.StructureToPtr(blob, ptr, true);
// Pass it by reference
// OK, now it's time to "reconsitute" the structure
blob = (CUnityDS.Blob)Marshal.PtrToStructure(ptr,
typeof(CUnityDS.Blob));
CUnityDS.DE_ERRORS errcode =
CUnityDS.DE_ERRORS.DE_MEMORY_ALLOCATION_FAILURE;
//EncodeAsnUser is a C unmanaged code that puts data from userContextData
struct to IntPtr
errcode = CUnityDS.LibWrap.EncodeAsnUser(ref blob, userContextData);
//Getting unspeficied error with the following line becuase it needs a
byte[] and not IntPtr
deNewContextObject.Properties["meetingBlob"].Add((object)blob.pData);
--
Thanks.
Pucca wrote:
Thank yuou Lit. The blob is returned to me but the length is not set. How
can I get the length of the IntPrt for the parameter? Thank you.
Marshal.SizeOf maybe.
Arne
"Pucca" <Pu***@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
Thank yuou Lit. The blob is returned to me but the length is not set.
How
can I get the length of the IntPrt for the parameter? Thank you.
--
Thanks.
Isn't nLength or nSize not the size of pData?
Willy.
Yes, that gives me the size of pData. Thanks.
--
Thanks.
"Arne Vajhøj" wrote:
Pucca wrote:
Thank yuou Lit. The blob is returned to me but the length is not set. How
can I get the length of the IntPrt for the parameter? Thank you.
Marshal.SizeOf maybe.
Arne
Hi Willy,
I thought it is. My code is calling a fucntion to encode the user structure
data into a blob. Well, as it turns out. I'm able to call it successfully
but the data is not encoded correctly into a blob. I just posted that
problem. It will be great if you can take a look at that. Thank you. (my
title of the problem is "Need Help declaring parameter variables for
DllImport c-code dll"). Thank you.
--
Thanks.
"Willy Denoyette [MVP]" wrote:
"Pucca" <Pu***@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
Thank yuou Lit. The blob is returned to me but the length is not set.
How
can I get the length of the IntPrt for the parameter? Thank you.
--
Thanks.
Isn't nLength or nSize not the size of pData?
Willy.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Swarup |
last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling
it into a byte arry. Now i have to convert it into a string to store it...
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the...
|
by: MuZZy |
last post by:
Hi,
I just wonder if someone can help me wit this -
i have a byte array and need to convert it to short array, creating
short numbers by...
|
by: dale zhang |
last post by:
Hi,
I am trying to save and read an image from MS Access DB based on the
following article:
...
|
by: moondaddy |
last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a
string, and then from a string back to a byte array.
for example
...
|
by: kyle.tk |
last post by:
I am trying to write a function to convert an ipv4 address that is held
in the string char *ip to its long value equivalent. Here is what I
have...
|
by: =?Utf-8?B?Um95?= |
last post by:
What is the way to have best performance to copy a byte to a value such as
long?
I use
BitConverter.ToInt64(binary, offset)
But the performace is...
|
by: Bob Altman |
last post by:
Hi all,
I'm looking for the fastest way to convert an array of bytes to String. I
also need to convert a String back to its original Byte()...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |