473,382 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Is it possible to Dllimport a function returning an ArrayList

I get the following exception when it tries to run the GetWindowsAndDoors function in C

An unhandled exception of type 'System.Runtime.InteropServices.MarshalDirectiveEx ception' occurred in WindowsApplication1.ex

Additional information: Can not marshal return value: The type definition of this type has no layout information

What is the correct way to do this. It's not like I have to marshall from one string type to another or anything. I get the sense that gc pointers to go through this mechanism. If this is the case, what would be a good way to handle this

Thanks

Inside of C+

extern "C

__declspec(dllexport) System::Collections::ArrayList* GetWindowsAndDoors(System::Int32 itemdefsClassID)
System::Collections::ArrayList* GetWindowsAndDoors(System::Int32 itemdefsClassID

System::Collections::ArrayList* al = new System::Collections::ArrayList()
// Do stuf
return al
Inside C

[DllImport("\\temp\\temp27\\output.dll")
public static extern System.Collections.ArrayList GetWindowsAndDoors(int itemdefsClassID)

... and Late

System.Collections.ArrayList al = GetWindowsAndDoors(1327)

Nov 15 '05 #1
1 1532
Dave,
What is the correct way to do this.


Forget P/Invoke and the DllImport attribute. Make GetWindowsAndDoors a
method of a public __gc class and reference the C++ assembly from C#.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2

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

Similar topics

2
by: Kurt Ng | last post by:
Hi, y'all. Can anyone help me on this problem? I'm working with a third-party C dll, and I'm having trouble importing into C# the dll's methods that return one of the dll's defined types,...
3
by: Rock | last post by:
I am getting an error: "Object reference not set to an instance of an object." when trying to use a function that returns an array list. Can I not do this, how would I set the instance of a...
0
by: Vizzybit | last post by:
I am attempting to utilise the HBAAPI.dll that can be found at http://hbaapi.sourceforge.net/ (which is also used in hbaverify at http://hbaverify.sourceforge.net/) as I need to get a small subset...
1
by: Matthias De Ridder | last post by:
Hello, I really hope that someone will be able to help me, because I'm desperate now! I'm a student, graduating this year, and I'm working on a thesis where C# Web Services are involved. I...
10
by: Sek | last post by:
I have a property that returns a ArrayList object. On failure condition, is it right to return null or return an ArrayList object with zero elements?
3
by: Terry Olsen | last post by:
I'm currently using the following function to return an ArrayList: Private Function ADSIReturnComputers(ByVal BldgMnemonic As String) As ArrayList Dim x As New ArrayList Using oDirectoryEntry...
8
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2, C# for Windows application. I use DllImport so I can call up a function written in C++ as unmanaged code and compiled as a dll us vs2005. My application is able to...
3
by: Elikhom | last post by:
Hi, I'm trying to call a C++ function that has a char** as a parameter from C# code using DllImport. After googling around and finding some threads I haven't been able to solve my problem. This is...
2
by: =?Utf-8?B?RHJldw==?= | last post by:
I have a current requirement to all a subsidiary to use a current legacy application and interface with my new system to inject data when appropriate. I wanted to create a web service since we are...
1
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...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.