Hi there !
I have some Problems to get a SafeArray out of a COM Server written in
(Unmanaged) C++.
From (unmanaged) Visual Basic , everything is ok , but unfortunately
in C# I get an exception.
Can anybody help me ?
Thanks a lot !!
Roland
----------------C++ (unmanaged) COM Server Method--------------------
[id(1206), helpstring("met hod GetData")] HRESULT GetImageData(
[in,out]SAFEARRAY(int) *ppsa);
//
*************** *************** *************** *************** ***********
STDMETHODIMP GetImageData(SA FEARRAY** ppsa)
//
*************** *************** *************** *************** ***********
{
// prepare 2 dimensional safearray
SAFEARRAYBOUND rgsabound[2];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 512;
rgsabound[1].lLbound = 0;
rgsabound[1].cElements = 512;
*ppsa = SafeArrayCreate (VT_I4, 2, rgsabound);
....
...Filling the SafeArray with the desired Image Data....
}
/*************** *************** *************** *************** *************** *************** *************** *****
-----------(Managed) C# Client ---------------------------------------
private void GetImageData()
{
int[] lengthsArray = new int[2] { 512,512 };
int[] boundsArray = new int[2] { 0 ,0};
Array data = Array.CreateIns tance( typeof(int), lengthsArray,
boundsArray );
//----------------------------COM Call //
m_theComServer. GetImageData(re f imagedata);
//Here I get an exception!!!!!! !!!!!!!!!!!!!!! !!!//
} 4 10323
Roland,
How are you accessing the unmanaged code? Can you provide a sample?
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com
"Roland Moschel" <mo**@gmx.de> wrote in message
news:rh******** *************** *********@4ax.c om... Hi there !
I have some Problems to get a SafeArray out of a COM Server written in (Unmanaged) C++.
From (unmanaged) Visual Basic , everything is ok , but unfortunately in C# I get an exception.
Can anybody help me ?
Thanks a lot !!
Roland
----------------C++ (unmanaged) COM Server Method--------------------
[id(1206), helpstring("met hod GetData")] HRESULT GetImageData( [in,out]SAFEARRAY(int) *ppsa); // *************** *************** *************** *************** *********** STDMETHODIMP GetImageData(SA FEARRAY** ppsa) // *************** *************** *************** *************** ***********
{ // prepare 2 dimensional safearray SAFEARRAYBOUND rgsabound[2]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = 512; rgsabound[1].lLbound = 0; rgsabound[1].cElements = 512; *ppsa = SafeArrayCreate (VT_I4, 2, rgsabound); ... ...Filling the SafeArray with the desired Image Data.... }
/*************** *************** *************** *************** ***************
*************** *************** *****
-----------(Managed) C# Client ---------------------------------------
private void GetImageData() { int[] lengthsArray = new int[2] { 512,512 }; int[] boundsArray = new int[2] { 0 ,0};
Array data = Array.CreateIns tance( typeof(int), lengthsArray, boundsArray );
//----------------------------COM Call //
m_theComServer. GetImageData(re f imagedata);
//Here I get an exception!!!!!! !!!!!!!!!!!!!!! !!!// }
Sorry, but I had a little Bug in my Posting...
-----------(Managed) C# Client ---------------------------------------
private void GetImageData()
{
...
m_theComServer. GetImageData(re f data ); <-----------
...
}
Roland,
Are you using VS.NET to create the .NET wrapper? Or are you using
TLBIMP, or are you coding the interface by hand?
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com
"Roland Moschel" <mo**@gmx.de> wrote in message
news:lq******** *************** *********@4ax.c om... Sorry, but I had a little Bug in my Posting...
-----------(Managed) C# Client ---------------------------------------
private void GetImageData() { ...
m_theComServer. GetImageData(re f data ); <-----------
... }
Hi Nicholas,
I tried both, using the VS.NET and tlbimp with and without /sysarray
But everything didn´t work.
Roland
On Tue, 7 Oct 2003 12:24:00 -0400, "Nicholas Paldino [.NET/C# MVP]"
<ni************ **@exisconsulti ng.com> wrote: Roland,
Are you using VS.NET to create the .NET wrapper? Or are you using TLBIMP, or are you coding the interface by hand? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: GeRmIc |
last post by:
Hi,
I am doing an interop from unmanaged code to C#.
How do i pass an ArrayList pointer from an unmanaged code, (structres are
easily passed by between C# and C).
//This is the C code
NameStruct lnames; //This is a structure in C#
|
by: Niklas |
last post by:
Hi
I'm creating a .NET dll, which I will use in VB 6. I have no problem
declaring methods, which will take a single Object, String, Integer and so on
as a parameter. I manage even to transfer arrays of Strings and integer, but
I fail to pass an array of Objects in a parameter. How do I declare a method,
where one of the parameters is an Object array, in .NET, which I will use in
VB6?
Regards
/Niklas
|
by: Tim |
last post by:
When there is a need to pass some dynamic information between 2 managed
assemblies, the "Dictionary object" in Generic form can be used as a method
parameter to pass the information. The information that needs to be passed
can be stored as Key-Value pairs, and the method signature remains the same.
That way, handling future requirements of passing additional details to the
callee can be handled without changing the method signature.
Is...
|
by: Maxim |
last post by:
Hi all,
I'm calling a COM Interface method that returnes SafeArray wrapped into
variant. Is it possible to convert it to managed array? Because working with
SAFEARRAY directly is a bit complicated. Or maybe there is a managed wrapper
class for safe array?
Thanks in advance.
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need to show the array data to the end user.
Can I do that?
How?
| |
by: Christian Schmidt |
last post by:
Hi all,
I need to implement an unmanaged function that gets a SafeArray and
hands it over to a managed function having the managed array-type.
Using MarshalAs I can call unmanaged functions having SafeArray from
managed code. But here I need this vice-versa...
I assume it is doable with MarshalAs magic, but how?
Thanks
Christian
|
by: cskarp |
last post by:
I have create a .Net component which exposes an interface with two methods. The first method takes an array of structs as a parameter the other method returns an array of (the same tyoes of) structs.
When I get the array structures from my second method in unmanaged c++, I cannot regonize any of the parameters in the structures. But if I pass the same pointer to the first method in my interface and look at the values in .net then thay are...
|
by: eitanyan |
last post by:
I am trying to create a Java to .Net interop and the way I am doing it is by creating a C# com object and a native unmanaged c++ dll that uses JNIEnv of java.
the java is loading the native c++ dll and invokes a method in it which invokes a method on
The command passed from java to .Net is a byte array and the response passed back is also a byte array
the C# managed COM object which finally invokes a method on a regular C# managed dll....
|
by: skeptics |
last post by:
Trying to pass a SafeArray that i get form Request.BinaryRead Method in classic asp to a c# com interop component. In this thread i found a solution to pass and cast a normal asp safearray in to a c# array: http://bytes.com/groups/net/114755-passing-safearray-bytes-vbscript-managed-com-object-c#goto_threadtools
but no matter what i try. i cant pass a array that i get from Request.BinaryRead Method in to the component. i always get a error...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |