473,804 Members | 3,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

From Unmanaged, unsafe to Managed, safe...


Hi Newsgroup,

General C# questions. If I have a class(es), of API functions just as they
are. Would that be considered Unmanaged or unsafe (not meant as the c#
keyword) code? If I implement error checking, and disposing appropriate
resources for those functions would my program then be considered managed
(or safe)?

In general I'd like to ask (not just with API functions) can you construct
an assembley that would confirm to the definition (I don't really know it)
of Managed code with respect to the .NET Framework, from using unmanaged
resources? So that if you passed that assemebley to someone else, you could
say, it's managed and hence safe. If it can, what guide lines should be
followed?

SpotNet
Nov 17 '05 #1
2 1524
Code executing under the control of the runtime is called managed code.
Conversely, code that runs outside the runtime is called unmanaged code. COM
components, ActiveX interfaces, and Win32 API functions are examples of
unmanaged code. Runtime here is called Common Language Runtime ( CLR )

--
Vadym Stetsyak aka Vadmyst
"SpotNet" <Sp*****@msnews .grp> wrote in message
news:O9******** ******@TK2MSFTN GP14.phx.gbl...

Hi Newsgroup,

General C# questions. If I have a class(es), of API functions just as they are. Would that be considered Unmanaged or unsafe (not meant as the c#
keyword) code? If I implement error checking, and disposing appropriate
resources for those functions would my program then be considered managed
(or safe)?

In general I'd like to ask (not just with API functions) can you construct
an assembley that would confirm to the definition (I don't really know it)
of Managed code with respect to the .NET Framework, from using unmanaged
resources? So that if you passed that assemebley to someone else, you could say, it's managed and hence safe. If it can, what guide lines should be
followed?

SpotNet

Nov 17 '05 #2

Thank you very much Vadym.

SpotNet

"Vadym Stetsyak" <va*****@ukr.ne t> wrote in message
news:uS******** ********@tk2msf tngp13.phx.gbl. ..
Code executing under the control of the runtime is called managed code.
Conversely, code that runs outside the runtime is called unmanaged code.
COM
components, ActiveX interfaces, and Win32 API functions are examples of
unmanaged code. Runtime here is called Common Language Runtime ( CLR )

--
Vadym Stetsyak aka Vadmyst
"SpotNet" <Sp*****@msnews .grp> wrote in message
news:O9******** ******@TK2MSFTN GP14.phx.gbl...

Hi Newsgroup,

General C# questions. If I have a class(es), of API functions just as

they
are. Would that be considered Unmanaged or unsafe (not meant as the c#
keyword) code? If I implement error checking, and disposing appropriate
resources for those functions would my program then be considered managed
(or safe)?

In general I'd like to ask (not just with API functions) can you
construct
an assembley that would confirm to the definition (I don't really know
it)
of Managed code with respect to the .NET Framework, from using unmanaged
resources? So that if you passed that assemebley to someone else, you

could
say, it's managed and hence safe. If it can, what guide lines should be
followed?

SpotNet


Nov 17 '05 #3

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

Similar topics

16
14144
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the byteArray and afterwards see the changes in C#. (if you wanna know more details: the goal is to write the content of an existing char-array in c++ precisely into the passed byteArray, so that after the function has proceded the content of the...
47
3544
by: Bonj | last post by:
I downloaded the gzlib library from zlib in order to do compression. (http://www.gzip.org/zlib) The prototype of the compression function seems to be int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); It is meant to be called by C, but I would rather use it from C#. So I wrote the following C# program to test it, but it failed to work. The call to compress doesn't return or throw an exception, it simply...
4
1248
by: apm | last post by:
Can calling conventions of functions be changed in unmanaged C# in a similar way that they can be changed using C++?
2
1612
by: The unProfessional | last post by:
Any know how to convert a managed array to an unmanaged array (ptr)? // Managed float f = new float ; // Unmanaged unsafe { float *pArray = f; // No good
1
3045
by: sklett | last post by:
STILL trying to wrap an unmanaged C++ class that is itself a wrapper to some COM stuff, not sure, it is littered with LPDISPATCH and InvokeHelper, etc. Problem is, when something goes wrong, I'm having a hard time debugging. In my managed C++ class(the one wrapping the unmanaged C++) I have a method that looks like this: bool FindFileItem(String* filename, IVSSItem& founditem); that method calls the unmanaged method:
5
1735
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
6
5900
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example will prove useful. structure MyStruct { // this is a complicated struct declaration in the sense
3
2215
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm trying to specify the requirement from unmanaged DLL component that will be used by a managed application written in C#. The unmanaged DLL is implementing some kind of algorithm for defect detection that will generate results. Each defect result should be a structure containing the data of the found defect. The number of defect is known only at the end of the algorithm at the unmanaged side. The managed application should get the...
0
1438
by: tomwolfstein | last post by:
Hi. I am trying to write a wrapper for the standard VC1 decoder, and I need to resolve a "TypeLoadException" The decoder comes an an executable which I've turned into a .dll. This decoder has about a ton of structures, most of the containing other structures, arrays of structures, and unions of structures. I need help converting the following to managed code: The unmanaged structure is this: typedef struct { vc1_eBlkType eBlkType; /**...
0
9588
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
10589
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10327
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
9161
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
7625
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
6857
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
4302
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
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.