473,383 Members | 1,803 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,383 software developers and data experts.

Exporting Managed Code as Flat API to Unmanaged World

Hi,

I have a MC++dll, whose functions i want to use in unmanaged c++. I
read that one of the ways to use the managed

functions in unmanaged world is by exposing the managed api as flat
api.
I tried that and with simple data types it worked. But now i need to
export a function which needs to take a gc

struct as parameter, and then fill some values in it, and then the
unmanaged c++ will use that info.

Here's what i did

//My gc struct
[StructLayout(LayoutKind::Sequential,CharSet=CharSe t::Ansi)]
public __gc struct STLayout {
public:
[MarshalAs(UnmanagedType::LPTStr)]
String* ID;
};
//End

Now i'm trying to export this through a funtion like this:-

__declspec(dllexport) int
ExportL([MarshalAs(UnmanagedType::Struct)]STLayout*& Layout)

And when i compile this dll. i'm getting the following error:-

error C3395: __declspec(dllexport) cannot be applied to a function
with the __clrcall calling convention

Now im stuck....
what i dont understand is that

1) why isn't the MarshalAs attribute working here.....
2) What is the preferred way of exporting the managed types to c+
+....other than the COM interop, mixed-mode

solutions......

Any other ideas...

Thanks in advance...
Saad.
Sep 26 '08 #1
0 1878

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

Similar topics

7
by: sachin | last post by:
Hi All, I have an application which is web based. I am hosting it on VB.Net container, ie winform. Now i am facing a problem. If i make an exe of that, then i require .net framework installed on...
0
by: nygiantswin2005 | last post by:
I would like to know how do I pass a pointer to a struct from managed code to unmanaged code. For example if I create structure like this in managed code. StructLayout( LayoutKind.Sequential,...
1
by: batista | last post by:
Hi, I have an unmanaged dll that uses callback to call a function of managed code.Now the problem is that it's given error "System.DllNotFoundException" I read it's due to appdomian....
0
by: Johannes Unfried | last post by:
Problem Best practice needed to marshal STL data from managed code to unmanaged code & vice vers Details managed code is written in managed C++ & accesses the unmanaged code (i.e. lives in a...
3
by: Marty | last post by:
Hi, Can I mix my managed code within my unmanaged code? Just for instance, I have a socket class that is managed code. It is include in my unmanaged VC++ project and it compile. The point...
4
by: Bae,Hyun-jik | last post by:
Hi, What is the best case for accessing managed code from unmanaged C++ code, considering that the unmanaged code doesn't have managed extension? Please reply. Thanks in advance. Regards,...
2
by: Tony Johansson | last post by:
Hello! Is the statements below correct understood. If I intend to use C++ in VS2005 I can either use managed code which is C++/CLI which give me the possibility to mix other language such as...
2
by: Ed | last post by:
Hello, dear all, I have a solution that contain the managed project and unmanaged project source code, and managed project will use the unmanaged project as a library. The debugging in the...
0
by: guy.tzur | last post by:
Hi All, I was wondering if there is an option to invoke managed code from unmanaged code (c/c++) without the need to expose the .NET code as COM. What I'm looking for is an in-process option to...
1
by: Saad | last post by:
Hi, I have a MC++dll, whose functions i want to use in unmanaged c++. I read that one of the ways to use the managed functions in unmanaged world is by exposing the managed api as flat api. I...
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
isladogs
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...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.