473,396 Members | 1,827 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,396 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 1881

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: 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
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...
0
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,...
0
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...
0
Oralloy
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.