473,726 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unmanaged C functions and C++ classes wrapped in an assembly not as public but as managed private methods: how???

Hello,

in the last few days I've made my first few attempts at creating mixed C++
managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is
visible in those assemblies from a managed point-of-view I've noticed that:

1) for each managed and unmanaged C function (not C++ classes) I get a
public managed static method (defined on a 'Global Functions' class) in the
generated assembly with an export name of the form xyz.FunctionNam e, where
xyz looks like a C++ mangled random name. As global methods of this 'Global
Functions' class also appear the main and _mainCRTStartup functions and any
other C library function that gets used inside the defined managed or
unmanaged C functions. In my simple sample applications, for example, I'm
using the printf C standard library function inside my definined functions
and when looking at the generated assembly with ILDASM I find a public
managed static method with the same name.

2) for each unmanaged C++ class I get a public managed structure (value
class) with no managed method visible. Including any C++ standard library
(such as iostrem, string, ecc.) in a project also adds a lot of managed
objects in the form of public managed structures (value classes). And this
happens even if none of the included C++ standard library classes gets used
in the defined managed/unmanaged C++ classes.

All of the above happens when compiling assemblies in release mode and
having specified to have the compiler produce NO debugging information.
Incredibly I discovered that even for release compiled assemblies some
debugging information still is produced and inserted into the assembly. Look
under "Project Properties -> C/C++ -> General" and set Debug Information
Format to Disabled to stop debug info from being placed into your
assemblies.

Now, what I'd like to do is:
(1) hide, if possible, any managed objects (value classes, arrays and
fields) created around my unmanaged C functions and C++ classes, but most of
all
(2) I'd like to have all these managed structures (value classes) created
around my managed/unmanaged C functions and unmanaged C++ classes to be
PRIVATE and NOT PUBLIC as their are created now.

I've tried defining as static both the managed and unmanaged C functions but
this does not seem to change anything. As for the C++ unmanaged classes it
seems that access specifiers (public, private, protected) may only be
applied to managed classes and so on this front I have not been able to do
anything.

Can anyone help me out???
Thx.
Bob Rock



Nov 17 '05 #1
3 4206
Note: I set follow-ups to m.p.d.languages .vc.
(2) I'd like to have all these managed structures (value classes) created
around my managed/unmanaged C functions and unmanaged C++ classes to be
PRIVATE and NOT PUBLIC as their are created now.
Compile with /d1PrivateNative Types for the value classes created mapping the
native types.

There is no alternative for the global functions since they are really
needed. Also no current tool (including ILASM) can call global functions )in
the CLR sense) exported from an assembly.
(1) hide, if possible, any managed objects (value classes, arrays and
fields) created around my unmanaged C functions and C++ classes, but most
of
all
If by "hide" you mean "not generate"then that isn't possible since these are
needed for the code to run. If you mean something else besides emitting them
as private, could you clarify?

Thanks.

Ronald Laeremans
Visual C++ team

"Bob Rock" <no************ *************** @hotmail.com> wrote in message
news:uU******** *****@tk2msftng p13.phx.gbl... Hello,

in the last few days I've made my first few attempts at creating mixed C++
managed-unmanaged assemblies and looking aftwerwards with ILDASM at what
is
visible in those assemblies from a managed point-of-view I've noticed
that:

1) for each managed and unmanaged C function (not C++ classes) I get a
public managed static method (defined on a 'Global Functions' class) in
the
generated assembly with an export name of the form xyz.FunctionNam e, where
xyz looks like a C++ mangled random name. As global methods of this
'Global
Functions' class also appear the main and _mainCRTStartup functions and
any
other C library function that gets used inside the defined managed or
unmanaged C functions. In my simple sample applications, for example, I'm
using the printf C standard library function inside my definined functions
and when looking at the generated assembly with ILDASM I find a public
managed static method with the same name.

2) for each unmanaged C++ class I get a public managed structure (value
class) with no managed method visible. Including any C++ standard library
(such as iostrem, string, ecc.) in a project also adds a lot of managed
objects in the form of public managed structures (value classes). And this
happens even if none of the included C++ standard library classes gets
used
in the defined managed/unmanaged C++ classes.

All of the above happens when compiling assemblies in release mode and
having specified to have the compiler produce NO debugging information.
Incredibly I discovered that even for release compiled assemblies some
debugging information still is produced and inserted into the assembly.
Look
under "Project Properties -> C/C++ -> General" and set Debug Information
Format to Disabled to stop debug info from being placed into your
assemblies.

Now, what I'd like to do is:
(1) hide, if possible, any managed objects (value classes, arrays and
fields) created around my unmanaged C functions and C++ classes, but most
of
all
(2) I'd like to have all these managed structures (value classes) created
around my managed/unmanaged C functions and unmanaged C++ classes to be
PRIVATE and NOT PUBLIC as their are created now.

I've tried defining as static both the managed and unmanaged C functions
but
this does not seem to change anything. As for the C++ unmanaged classes it
seems that access specifiers (public, private, protected) may only be
applied to managed classes and so on this front I have not been able to do
anything.

Can anyone help me out???
Thx.
Bob Rock




Nov 17 '05 #2
> Compile with /d1PrivateNative Types for the value classes created mapping
the
native types.

If by "hide" you mean "not generate"then that isn't possible since these are needed for the code to run. If you mean something else besides emitting them as private, could you clarify?

Ronald Laeremans
Visual C++ team


Ronald,

I tried compiling with the /d1PrivateNative Types. It compiles fine, and it
makes private the value classes created for the unmanaged classes,
unfortunately it does NOT make private the managed methods created around
the C functions (either managed or unmanaged). Is there any way to make them
private???
BTW, the /d1 option does not appear anywhere printing out all the modifiers
supported by the cl compiler.

Also, while for C standard library functions only the ones used produce a
corresponding managed wrapper in the assembly, for C++ stardard functions
the only inclusion (without using any of the exported classes) make an awful
lot of value classes appear in the assembly. Is there any way to prevent
this from happening???
Regards,
Bob Rock
Nov 17 '05 #3
Hi Bob,

I tried compiling with the /d1PrivateNative Types. It compiles fine, and it
makes private the value classes created for the unmanaged classes,
unfortunately it does NOT make private the managed methods created around
the C functions (either managed or unmanaged). Is there any way to make
them
private???
No, that is what I tried to describe by the following paragraph in my
original reply:

There is no alternative for the global functions since they are really
needed. Also no current tool (including ILASM) can call global functions )in
the CLR sense) exported from an assembly.
<<
BTW, the /d1 option does not appear anywhere printing out all the
modifiers
supported by the cl compiler.
Yes, the following link is the only available documentation:
http://support.microsoft.com/default...b;en-us;822330

Also, while for C standard library functions only the ones used produce a
corresponding managed wrapper in the assembly, for C++ stardard functions
the only inclusion (without using any of the exported classes) make an
awful
lot of value classes appear in the assembly. Is there any way to prevent
this from happening???

No there is not one that I know of. There should be no ill effects though.
Do you have a specific concern?

Ronald
Nov 17 '05 #4

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

Similar topics

1
741
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form...
0
1305
by: david chang via DotNetMonster.com | last post by:
Hi, guys I am trapped into a big trouble on how to use unmanaged class library code in a C# web application. Now, I am working on a project to develop a web interface for SPlus, a statistical software tool. By intuitive, I plan to apply C# to develop web side, which will invoke some unmanaged code to use functions of SPlus. I have developed a unmanaged C++ class UM_A to use SPlus functions, and also developed a wrapped managed C ++ class...
4
40025
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that deals with managed in one place, and code that deals with unmanaged in another place, but I can't seem to find anything that clearly explains what that means. I think if I used a Windows API function to optain a handle, that handle would be an...
0
1284
by: Vasco Lohrenscheit | last post by:
Hello, I have problems with pointers to unmanaged classes as parameters for virtual methods, and then overwriting the virtual methods in other assemblies: //GUI.dll #include "../Plugin/iPlugin.h" //unmanaged plugin interface header public __gc PluginGui : public Windows::Forms::Form
2
2055
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking afterwards with ILDASM at what is visible in those assemblies from a managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form
5
1734
by: Andrew | last post by:
I want to use a managed c++ class from an unmanaged class. Here is my code: // *** Unmanaged Code // .h file class UnmanagedClass { public: // Other stuff here
3
1999
by: _BNC | last post by:
I have an old C DLL that I want to access via C#. I'm doing this via an outer DLL that wraps the old C DLL in an unmanaged C++ class, which is in turn wrapped in a Managed C++ class. Both these unmanaged C++ and managed C++ classes are compiled into a single assembly (DLL) that is accessed by C#. <--> <--> old dll new C++ assembly app
13
5050
by: bonk | last post by:
Hello, I am trying to create a dll that internally uses managed types but exposes a plain unmanaged interface. All the managed stuff shall be "wrapped out of sight". So that I would be able to use that dll from pure unmanaged code (for example inherit from classes in that dll). Is something like that possible. I heared something called ManWarp tried that approach. If it is possible, how can I do that. Maybe there is a small litttle
6
1311
by: marek | last post by:
Hello All, we are doing a quite a big project that contains at the lowest level an unmenaged c++ classes. Above it there are managed wrappers and at the top there are ASP.NET pages. Can anyone tell me how to force ASP.NET not to "clear" or reinitialize unmenaged global or static variables that are set on unmanaged level between successive requests?
9
3121
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for this, I want to use it. Is it possible to call Managed class functions from Unmanaged class? How to do it? I did something like this. I declared a managed class (in C++ CLI) called as MyManagedClass whose
0
8752
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,...
0
9259
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9182
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9120
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8101
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
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();...
1
3228
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
2
2639
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.