473,585 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling win32 C++ dll from C#

Hi there,

I need to make a call into an unmanaged DLL from a C# application, and I am
getting a SafeArrayTypeMi smatchException which basically means that either
what I am sending to the DLL is incorrect, or what I am getting out is not
what the C# code expects.

My question is this: How do I know which array is the troublesome one?
Within the call there are numerous arrays all contained within different
structs.

Regards,

FV
Jan 5 '07 #1
3 2903
Can you post the function prototype? I'd guess there's some sort of
pointer to a buffer and a length parameter as a minimum?
FrancoisViljoen wrote:
Hi there,

I need to make a call into an unmanaged DLL from a C# application, and I am
getting a SafeArrayTypeMi smatchException which basically means that either
what I am sending to the DLL is incorrect, or what I am getting out is not
what the C# code expects.

My question is this: How do I know which array is the troublesome one?
Within the call there are numerous arrays all contained within different
structs.

Regards,

FV
Jan 5 '07 #2
FrancoisViljoen wrote:
[DllImport("file name.dll", EntryPointentry pointname")]
private static extern int DoStuff(ref Series pData, ref StdStat
pStdstat, ref Settings pSettings, ref EXSM pExSm, ref BOXJ pBj, ref SMA pSma,
ref Dscr pDsc, ref Croston pCroston);

where each of the parameters is a struct of which some contain arrays.


"DeveloperX " wrote:
>Can you post the function prototype? I'd guess there's some sort of
pointer to a buffer and a length parameter as a minimum?
FrancoisViljoe n wrote:
>>Hi there,

I need to make a call into an unmanaged DLL from a C# application, and I am
getting a SafeArrayTypeMi smatchException which basically means that either
what I am sending to the DLL is incorrect, or what I am getting out is not
what the C# code expects.

My question is this: How do I know which array is the troublesome one?
Within the call there are numerous arrays all contained within different
structs.

Regards,

FV
It's best that you can also post your code to show us how you call it.
Jan 5 '07 #3

"FrancoisViljoe n" <francoisv at dev dot barloworldoptim us dot comwrote in
message news:C8******** *************** ***********@mic rosoft.com...
[DllImport("file name.dll", EntryPointentry pointname")]
private static extern int DoStuff(ref Series pData, ref StdStat
pStdstat, ref Settings pSettings, ref EXSM pExSm, ref BOXJ pBj, ref SMA
pSma,
ref Dscr pDsc, ref Croston pCroston);

where each of the parameters is a struct of which some contain arrays.
When you define those structs in C#, you probably need to be using the
"fixed" keyword, otherwise C# assumes they are SAFEARRAYs.
>

"DeveloperX " wrote:
>Can you post the function prototype? I'd guess there's some sort of
pointer to a buffer and a length parameter as a minimum?
FrancoisViljoe n wrote:
Hi there,

I need to make a call into an unmanaged DLL from a C# application, and
I am
getting a SafeArrayTypeMi smatchException which basically means that
either
what I am sending to the DLL is incorrect, or what I am getting out is
not
what the C# code expects.

My question is this: How do I know which array is the troublesome one?
Within the call there are numerous arrays all contained within
different
structs.

Regards,

FV


Jan 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2340
by: Luca Arena | last post by:
Hi, I would like to know if it is possible to call the php parser from a Win32 program (e.g. a VB or C++ program), WITHOUT calling the commandline php.exe utility. I mean, is there any "php_parse" function, exported by the php5ts.dll, which I can declare in my Win program and then call to parse a php script? Thanks in advance Luca
8
1460
by: Patrick Useldinger | last post by:
Hi all, I am looking for beta-testers for fdups. fdups is a program to detect duplicate files on locally mounted filesystems. Files are considered equal if their content is identical, regardless of their filename. Also, fdups ignores symbolic links and is able to detect and ignore hardlinks, where available. In contrast to similar...
3
8745
by: gerald.maher | last post by:
I am trying to run an Corba example using Python and i get the follwing error: import _omnipy ImportError: No module named _omnipy Where can i find this Module ?
5
2505
by: nbotw | last post by:
Hi, I need a function call in my xml web service. I have an old win32 dll and i have created a class to have my declaration in. Imports System.Runtime.InteropServices Public Class Win32
0
303
by: Dale McGorman | last post by:
The following is some code that I am trying to bring over from VB 6.0, that I have working there. I am trying to get to where I can talk to a USB device. I am stuck on how to correctly pass params to the API call SetupDiGetDeviceInterfaceDetail() I can get it to actully not fail, and it actully tells me that it returned 87 bytes which is...
15
11757
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that performs the query is contained in a delegate function that I execute via a second thread. On 1 or 2 of the 600+ servers the query hangs. I've tried to...
1
1569
by: Wilfried Mestdagh | last post by:
Hi, I have a few related questios: 1. if I pass a string to win32 api (or other dll not written in .net), is it possible GC cleans up while function is still busy ? eg: public class Win32 {
11
1955
by: j23 | last post by:
I have library (static) testlib.cpp: #include <stdarg.h> void xxx(...) { char buf; va_list args; va_start(args, buf); va_end(args); }
0
1168
by: Scott Gunn | last post by:
Hello I'm trying to scroll a region of graphics, the best way I can see is to use the ScrollWindowEx API because it is designed for doing this However it doesn't work correctly, Why? Here is my code: Public Class Win32
2
2811
by: Daniel Lidström | last post by:
I'm using a library called fyba. This library reads and writes files in a format called sosi. fyba uses the following code to determine if the calling process has own methods to handle errors, messages, etc: // If this parameter is NULL, // GetModuleHandle returns a handle of the file used // to create the calling process. hInstExe =...
0
7908
marktang
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...
0
8336
jinu1996
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...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
tracyyun
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...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
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...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
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
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.