Click here to Skip to main content
15,879,239 members
Everything / Managed

Managed

managed

Great Reads

by pdoxtader
Very fast image processing without use of unsafe code
by Gaurav_Chhatbar
Object oriented implementation of basic language processing / parsing leveraging LINQ / PRISM / UnityContainer.
by Wessel Beulink
Azure API Center Portal streamlines API management; Visual Studio Code extension enhances collaboration and productivity within Azure ecosystem.
by Pero Matić
A detailed analysis of how to inject the .NET runtime and arbitrary .NET assemblies into unmanaged and managed processes; and how to execute managed code within those processes.

Latest Articles

by Wessel Beulink
Azure API Center Portal streamlines API management; Visual Studio Code extension enhances collaboration and productivity within Azure ecosystem.
by pdoxtader
Very fast image processing without use of unsafe code
by Mehul Donga
Handle managed (C#) event in managed (C++/CLI)
by Alexandre Bencz
DotNetPELib is a library which abstracts managed information such as namespaces, classes, fields, methods, and instructions. The information can then be used to generate assembly language source files, or PE executables or DLLs.

All Articles

Sort by Score

Managed 

30 Dec 2014 by OriginalGriff
No, C++ for example is usable in managed or unmanaged, it's the same language regardless.It's the framework that makes the difference there. Unmanaged code it a bit harder, because it doesn't do as much for you, it doesn't "hide" the nitty-gritty of what is going on behind a layer of...
18 Mar 2014 by OriginalGriff
Yes, any C# application is managed code - it is intimately tied to the .NET framework, so you will need that or a replacement such as one of the Mono variants to run any C# program, beit console or Winforms.You must have the appropriate .NET framework installed to run any .NET application.
17 Apr 2023 by pdoxtader
Very fast image processing without use of unsafe code
26 Feb 2011 by OriginalGriff
When you assign your LivingRoom to "r1", you do not assign a Room to it: you assign an inherited class, it is not truncated or otherwise converted to a Room. The Room variable "r1" will still work as a Room, you can access all of the properties and methods of a Room, but you cannot access the...
12 Oct 2011 by Sergey Alexandrovich Kryukov
They certainly can. You miss something.—SA
13 Oct 2011 by Espen Harlinn
You probably need to use #pragma managed(push,off)// Unmanaged code goes here#pragma managed(pop)See Using ACE with C++ CLI[^] for a working example.Best regardsEspen Harlinn
18 Oct 2011 by Sergey Alexandrovich Kryukov
First, "Managed C++" was superseded by C++/CLI which you tag, so this is hardly an option. Everything else really depends on details of your requirements and even of the level you are familiar with the technologies. In this case, it's not possible to justify any advice of the type "use just...
9 Mar 2014 by Sergey Alexandrovich Kryukov
I don't understand how could you miss this property: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.location%28v=vs.110%29.aspx[^].However, you should understand that this location is useful for assemblies which are not put in GAC. With assemblies in GAC, you will get...
15 Feb 2021 by amirea
I need to keep references in unmanaged code to objects on managed side, like handles. There are going to be approx. 10,000,000 objects. I'm not familiar with interop, initially I thought it was as simple as declaring ref SomeClass on C# side...
15 Feb 2021 by KarstenK
You shouldnt do that this way, but really think hard about using so many objects at once. If you really need that heavy load than you better code the program in one language to get best performance with that many objects. Else you can use the...
27 Aug 2011 by OriginalGriff
Don't post this under Questions & Answers - if you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.Posting this here relies on them "dropping...
18 Oct 2011 by Simon Bang Terkildsen
WCFSeems lake a hassle, to me, to write a host implementation of WCF in unmanaged C++.SocketsThis is an option, however I've never really used them so I don't know how feasible it is. That said if you need to communicate with something like Java where you can't use Named Pipes.Named...
18 Oct 2011 by Espen Harlinn
If you want to get the job done in a hurry - use COM Interop[^].Net has great support for COM, and COM enabling an MFC app is usually a straight forward process.Best regardsEspen Harlinn
7 Nov 2011 by OriginalGriff
dynamic_cast
7 Jan 2012 by Sergey Alexandrovich Kryukov
Your code is not quite clear to me, but providing a data structure that looks like an array for a user and is not an array in implementation is quite easy:internal struct Element {/*..*/} //or classclass ElementContainer { internal Element Add(Element element) {/*...*/ return...
24 Jan 2012 by Michael Haephrati
To begin with you should change c++ into cp++ for(cp=0;cp
29 Feb 2012 by Espen Harlinn
Have a look at:Using ACE with C++ CLI[^]Why not create a mixed mode C++/CLI dll? Declare structures that are convenient to use in c# and just copy from the original c structures to your new structures ...Best regardsEspen Harlinn
18 Sep 2012 by lewax00
Add a handler for the Changed event on the watcher. If you've figured it out for Created I'm guessing you can figure out how to attach it.
8 May 2013 by Sergey Alexandrovich Kryukov
You can do it by using C++/CLI and mixed-mode (managed+unmanaged) project. You can really use "regular" C++ classes with C++/CLI "ref" classes. You can really wrap a "regular" C++ class or struct around some "ref" types used in the implementation of the wrapper class.Everything else depends...
25 Jun 2013 by Aydin Homay
HiWhy you don`t used C++/CLI for this purpose? I suggest to you use if because CLI technology provide a really good environment and falsity to the simultaneous use of native and managed code. for getting more information about it please follow of links:Using .net 4 library from MFC...
19 Jul 2013 by Gaurav_Chhatbar
Object oriented implementation of basic language processing / parsing leveraging LINQ / PRISM / UnityContainer.
5 Dec 2013 by Dave Kreskowiak
Like has been said already, that tool already exists for COM-based libraries.It's impossible to write such a tool for standard libraries. The reason is that parameter and return value information is not stored in the library. Only the function names being exported can be found.
23 Sep 2014 by Joan M
Hello all,I have a robot which has only one NIC that has two virtual addresses: a) 192.168.1.X This address will be used to connect the robot to a PLC. b) 192.168.1.Y This address will be used to connect the robot to the customer LAN.Would a managed switch be able...
3 Jan 2015 by Mehdi Gholam
Generally "native code" meaning compiled directly to the CPU instructions is faster, however in some circumstances "managed code" running on a "virual machine" can be faster.So you really have to try and see which works best for your situation.
5 May 2015 by Sergey Alexandrovich Kryukov
Using unmanaged code in managed is not a big problem, but this is a very unpleasant problem, using P/Invoke and perhaps complex marshaling. You have a very good opportunity to get away from ramming such problems, to resolve problems really painlessly, but it looks like you are ignoring...
26 Jan 2016 by Richard Deeming
The argument is an event handle. Try changing the declaration to:[DllImport("fbwflib.dll", CallingConvention = CallingConvention.Winapi)]static extern UInt32 FbwfCacheThresholdNotification(UInt32 threshold, Microsoft.Win32.SafeHandles.SafeWaitHandle thresholdNotification);You should...
1 Feb 2024 by Wessel Beulink
Azure API Center Portal streamlines API management; Visual Studio Code extension enhances collaboration and productivity within Azure ecosystem.
20 Jul 2010 by Soorali
Hi All,I am a newbie to VC++ and this is my first independent project so please pardon my ignorance!!My project compiles and runs perfectly fine in Debug mode.However, when I try to compile it in Release mode ( I need this to use the Setup wizard for application Deployment) I get the...
23 Jul 2010 by Emilio Garavaglia
Check the project options about the support of CLR and managed code: probably the debug and the release ones are incoherent.
1 Oct 2010 by Jaffna33
hi...I need to return a managed unsigned short array to native c++unsigned short CPPWrapper::Factors(void){ array^ aaa = bb->Factors(a,0); pin_ptr pus = &aaa[0]; // this pin_ptr is not working for unsigned shortreturn pus // will be used...
1 Oct 2010 by E.F. Nijboer
Pinning pointers cannot be used as the return type of a function. Have another look at the link below to check what can and cannot be done. http://msdn.microsoft.com/en-us/library/1dz8byfh%28v=VS.80%29.aspx[^]Good luck!
1 Nov 2010 by JoaoPe
This is a Windows Forms Application project using Visual Studio 2010. That being said:I've an unmanaged 'Vector' implementation, something like: template class Vector { public: T* data; unsigned len; (...constructors and...
1 Nov 2010 by Nish Nishant
The template type you've used for instantiating cells is gcroot, but the type of cell is gcroot*. Change the template type of cells to match what you want. BTW, I am not sure what you will achieve with empty gcroot instances, since the idea is for them to point to a valid managed...
2 Nov 2010 by Nish Nishant
Here's some sample code based on your comment in the other reply.// assuming old style MC++ syntaxbool ConvertToStringBoolean(String* input){ return input->ToLower() == "true";}// Usagebool myBool = ConvertToStringBoolean("True"); // myBool will be truemyBool =...
2 Nov 2010 by aayu
HIFriends i need to convert TCHAR to Boolean value for example_TCHAR gstrEnableproxy="false"o/p:boolean x=falsewant this as an Out Putand the code i have written is void convertStringBoolean(String* TCHAR){ bool boolVal = false; try { boolVal =...
2 Nov 2010 by #realJSOP
0) Change the String parameter to something more appropriate, like str. String is a kweyword in some C++ namespaces.1) Why write a function when you can just do this:bool x = (str == 'true') ? false : true; Of course, you should probably convert str to lowercase for the comparison to...
3 Nov 2010 by radix3
Ok looking at the above conversations let me tell u first that the way have got this problem is that Ms.Aarti2010 is trying to get some character data and is trying to check whether data is present or not via printing some boolean result.I am not a VC++ guy but i am good in C# so...
21 Nov 2010 by suman@dinhy
Hi all, I need your help. I've wrote a WPF APP which need to catch the ScreenSaver event on Win7. I first wrote DLL in C++. When the dll is loaded,I set two delegate callbacks to the HOOK dll by call InstallHook(HOOKPROC _callBack,HOOKPROC _callBack2,HWND _mainwin), but the...
21 Nov 2010 by Manfred Rudolf Bihy
I know I might get hit for this, but ...would you please try to add this to your InstallHook function:if(myVolatile == 42){ MessageBox(0,_T("hooked!"),_T("note"),1);}and globally declare:volatile int myVolatile = 0;I'm just curios if it has something to do with...
21 Nov 2010 by suman@dinhy
I Fixed The Problem by Using [dllimport] to load the dll instead of LoadLibrary(...)BUT Still doubt about the MessageBox(...) magic.
26 Feb 2011 by Sergey Alexandrovich Kryukov
You apparently unaware of the very object-oriented fundamentals.First to understand: there are two different types involved: compile-time and run-time type.class MyBaseClass { internal byte somethingOld; }class MyDerivedClass : MyBaseClass { internal int somethingNew;...
9 May 2011 by Debojyoti Majumder
Try to use #pragma once in the header file MyInterface.h.That might solve the problem.
9 May 2011 by Olivier Levrey
There are 2 options:1- Create a nother dll which will contain your base interface. And reference this dll in your other assemblies (the dll containing the derived classes implementing this interface, and the exe)2- Make one of your existing dlls reference the other one which will contain...
9 Oct 2011 by Sankar Kuppusamy
Hi Friends,I have developed an application in WPF with C#. The application includes a third party dll for displaying the camera in a particular window. Normally the application takes the memory 90 MB - 135 MB without camera object (Unmanaged object). i.e I removed all the code reagrding...
9 Oct 2011 by Mehdi Gholam
Obviously there is a memory leak in the third party component you are using.I would suggest you contact them and have them look into the matter, as there is very little we can do for you here.Having said that try using a memory profiler to see where exactly you are leaking memory, that...
13 Oct 2011 by Shashidhar Kamath
Hello,I have a old native MFC/c++ dll I have managed to get it compiled with /CLR flag. Now I have added a managed C++/CLI class to the dll within a namaspace. The header file is below, and the cpp file only has #include for the header file.The native dll is a huge dll project with...
13 Oct 2011 by Shashidhar Kamath
I was trying to simplify my problem posted herehttp://www.codeproject.com/Questions/267721/native-dll-built-with-CLR-flag-containing-a-manage/?cmt=164099#cmt2_267721I created a MFC dll and added a manged C++ class to it (same class as the one in the above post) . Compiled with /CLR flag....
13 Oct 2011 by Shashidhar Kamath
I found the problem... I had to compile my Winform application in x86 mode, because the default any CPU was getting compiled on 64bit.I still have to figure out why my larger application dll is not workingShashi
18 Oct 2011 by sundararaman
I'm required to design the bidirectional distributed communication between legacy (MFC based VC++ application) and .NET GUI application (going to be built in C#). I have considered several approaches like Managed C++ (IJW), WCF (as a framework for communciations), Sockets, Named Pipes. Please...
19 Oct 2011 by luke2
Thanks for your replies. Both below solutions work:char* xx3 = wrapped->AAA();String* ret = wrapped->AAA();but what about memory management? Is it OK or causes memory leaks?
7 Nov 2011 by amir.dar
hi guys.i have a CLR project and a c++ managed class.i need to mimic the behavior of the "is" keyword from c# but i dont know how to do it in managed code.part of my code:1.C# code:public class emailMsg : Msg{ string email;}2.C++ manged codeMsg^ msg = gcnew...
7 Jan 2012 by EveryNameIsTakenEvenThisOne
The DLL:public static List RequestDialoge(int NPCID,int Control) { List CombinedPacket = new List(); CombinedPacket = Dialoge.Create(NPCID, Control); return CombinedPacket; } How i want to use it:int...
24 Jan 2012 by Richard MacCutchan
You cannot cast a string to a char. Just because you have a single character in your string does not make it into a character constant, it remains a string but with only one character in it.
15 Feb 2012 by ukJohnct1
We have an old VSE Smalltalk application and we want to be able to call a c# webservice that will return a string.I have been unable to get any call to a managed dll working from Smalltalk but I have been able to create a c++ win32 dll that can be called from Smalltalk, which in turn can...
15 Feb 2012 by Sergey Alexandrovich Kryukov
Yes, I basically know how Smalltalk works. If you can load a regular unmanaged DLL and call some of exported function, it would be enough to load use a .NET assembly, but this is not easy at all. I don't want to discuss a way of implementation of COM component, I'm taking about the ability to...
29 Feb 2012 by vamoose
Hi All,After a lot of searching the web and trying different things, I am still no closer to solving the following:I have written a c++ managed dll that is supposed to act as a wrapper for legacy c code. The c code uses a lot of structures that is filled with data from a host...
29 Feb 2012 by nortee
Hi,I haven't used marshalling in C#, so I am just taking a stab in the dark with this but is there any particular reason why you are using static? Maybe that is the root of your problem? The reason why I come to this conclusion is because I see this here:A static method, field, property,...
1 Apr 2012 by Adnan Merter
hi all,i need to find out how i can declare a global object which can be accesible from all functions of the same application.i created a global serialport object :System::IO::Ports::SerialPort^ serialPort = gcnew SerialPort(L"COM4" , 300, Parity::Even , 7, StopBits::One);then,...
1 Apr 2012 by Sergey Alexandrovich Kryukov
.NET does not have a concept of global objects (finally, thanks goodness!). Instead, you can have a static member of some managed "ref" class or structure.Formally, this solves your problem. But even this is not good enough, would be the sign of bad coding style.There are two ways of...
25 May 2012 by Mark Kruger
I Guess i would try something as the next, couldn't check if it worked though, i've nothin' alike.[DllImport("**YOURDLL**"]private static extern int VDGetPluginInfo();[StructLayout(LayoutKind.Sequential)]private struct VDPointer{ public int VDXPlugin;}public List...
3 Jul 2012 by Alexandre Bencz
Hi, I whant to know, how the C++/CLI compiler works, I generate 5 tree dumps of one simple code in C++/CLI3 tree dumps I generate with this simple code ( pure, safe CLR): using namespace System; int main(array ^args) { ...
18 Sep 2012 by AJ83
Hi,I have create service by using FileSystemWatcher for watching files in the folder. It is working fine when there is any new file arriving in the Folder and it is detecting and doing rest of job as expected.If there are files already present in Folder, How to Tell FileSystemWatcher to...
18 Sep 2012 by Kuthuparakkal
Use WMI and poll the reqd folder :string WMIQuery = "SELECT * FROM __InstanceCreationEvent WITHIN 10 " + " WHERE TargetInstance ISA \"CIM_DirectoryContainsFile\" and " + " TargetInstance.GroupComponent= " ...
7 Oct 2012 by Daniele Rota Nodari
Hi.Try add [ComVisibleAttribute(true)] to the class BasicCommandsClass.MSScriptControl uses COM technology to access to the object properties and methods, so if the class is not COM visible, it cannot be used by any script.Regards,Daniele.
29 Nov 2012 by 3umphant
This part. Commented code is cs. On compile catch an error:Error 78 error C3766: 'Sample::NoteInfo' must provide an implementation for the interface method 'System::String ^System::ComponentModel::IDataErrorInfo::default::get(System::String...
29 Nov 2012 by Qizhong Yang
Currently I need to load a C lib into my CLR project(managed c++/CLI).All the header file and lib file have been added. But when compile the project, there are some errors and warning like below:Errors:error LNK2001: unresolved external symbol "extern "C" int __stdcall...
29 Nov 2012 by 3umphant
Found the solution public: property String^ default[String^] { virtual String^ get(String^ index) { return GetColumnError(index); } }
30 May 2013 by RaMMicHaeL
I tried calling a function from a vb dotnet dll(from a cpp dll),this is my code#include "main.h"#include #include #pragma comment(lib,"mscoree.lib")void DLL_EXPORT SomeFunction(){ ICLRRuntimeHost *pClrHost = NULL; HRESULT hr =...
20 Jun 2013 by silentyears
First, I want to express my most sincere thanks to Sergey Alexandrovich Kryukov for my previous question "Host wpf control in vc6.0?" Beause the question has been closed so i have to thank you here, hope you can notice this.Now i want to know if i can call Managed code from Unmanaged code,...
19 Jun 2013 by Ron Beyer
Calling Managed Code from Unmanaged Code and vice-versa Article on CodeProject[^]
22 Oct 2013 by Narasimha Murthy SR
Hi ALL,How to read/Get or Invoke Parameter names and data type or interface name and datatype from an "Unmanaged" Dll..Please provide the sample in C#.
22 Oct 2013 by Richard MacCutchan
See http://msdn.microsoft.com/en-us/library/vstudio/1ez7dh12.aspx[^] and http://msdn.microsoft.com/en-us/library/56h2zst2.aspx[^].
22 Oct 2013 by Richard MacCutchan
See http://msdn.microsoft.com/en-us/library/vstudio/1ez7dh12.aspx[^] and http://msdn.microsoft.com/en-us/library/56h2zst2.aspx[^]. And, of course, Get all methods from a unmanaged DLL in C#[^].
9 Mar 2014 by C3D1
Hey Guys,i want to write a simple Application that show the depedencys from a (Managed)C# DLL or Application.Currently i'm trying this in C# but a solution in (unmanaged)VC++ is preffered.In C# i'm doing this with:Assembly MyAssembly = Assembly.LoadFrom( sPathToMyAssembly...
18 Mar 2014 by zalekbloom
I wrote a c# console application which created 3 files: a.exe, a.exe.config, a.pdb.Can I copy these files to any Win computer and execute it, or the computer needs correct .net framework and maybe some other stuff?Thanks,Zalek
29 Apr 2014 by Narasimha Murthy SR
the above Link will update us the Method/Function names but how to get the parameter Datatype and values ?
17 Nov 2014 by ravijmca
Basically my code is looks like below Managed.dllManaged.csclass MyManagedClass{public ShowMessage(){System.out.println("My Message");}}Wrapper.dllref class Wrapper{};Native.libclass NativeClass{public:void NativeMessage(){cout
17 Nov 2014 by KarstenK
It is an easy task. Look at this code from Microsoft.You could ofcourse use your dll and function.
17 Dec 2014 by CdnSecurityEngineer
I know and understand the introduction of windows service accounts, and how various applications run as Windows Service Account or a virtual account. I also know that one can connect to things such a File Share etc using a Managed Service Account. Has anyone ever tried to do anything like...
3 Jan 2015 by Ziya1995
Let's consider only cross platform managed code.I have read markup hybrid is slow and native is fast, but i don't know about managed code.Both of them are cross platform WORA (Write once, run anywhere).Performance is matter to me.What is faster? Managed code or markup hybrid...
13 Feb 2015 by thorssig
I've been trying to find a good minifilter example but it's not going well 8(I am looking for a simple minifilter skeleton that doesn't do much but allow registering of events from managed code in VS 2013, then forwards the File-System event to the application (which handles all the logic)...
5 May 2015 by RajneeshSaysHello
i have successfully created a single file of unmanaged c++ and used it into my c# application with both methods dll import and by creating a wrapper class for it. Now i have a created a whole project in c/c++ that uses various .lib, .in, .def,.asm, third party dll's and lib's along with my c...
12 Jul 2015 by Sergey Alexandrovich Kryukov
In addition to DirectX, you can consider:http://www.ogre3d.org[^],http://unity3d.com[^].—SA
26 Jan 2016 by Georg Newton
Hello all,I tried to use the function "FbwfCacheThresholdNotification" of the fbwf library of microsoft. The library is used in windows XP embedded and doesn't work on normal windows I guess. The documentation can be found here: [^]The documentation is insufficient for me. What managed...
9 Aug 2016 by catchy87
Hi All,I am trying to call managed C++ code from COM component and at the same time trying to call that COM component from VB.Net.Tried so many examples but none of them working.Can anybody help me with some pointers.*****Managed C++ code Start************namespace...
9 Aug 2016 by KarstenK
Take a look at this fine article series and this Q&A answers which I easily found with Google and am convinced that there are fine.I have another important tip: CoInitialize(NULL);//the call takes really CPU-timebecause some dlls are loaded and some code is running. Do it in the...
21 Dec 2017 by Greek Varak
I have a c# code that calls a dll (cpp build) and writes a text file (of 12 MB size) of txt file to a variable by calling a cpp dll Getting following errors : {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."} Additional information:...
30 Dec 2018 by OriginalGriff
If you want to, then yes - you have permission. If you want to know how, see here: SqlConnection Class (System.Data.SqlClient) | Microsoft Docs[^] - it includes a very basic example.
30 Dec 2018 by Patrice T
Quote: shall i connect sqlserver from managed c++ Depends if you need to access an SQL database.
20 Aug 2020 by Member 14919132
My managed code returns System::Collections::Generic::ICollection. I receive it in C++ by: auto failArr = op->messages I see that the type of failArr in C++ is array How do I get to the members of failArr? How can I...
17 Dec 2020 by Stefan_Lang
I'm working on a framework that is used within managed code, but relies on the native 3rd party library cereal[^]. I might have a problem with cereal's use of static variables: their instantiation causes Visual Studio to issue the warning...
3 Mar 2021 by OriginalGriff
Firstly,you aren't calling GetResponseAsync in that code. Secondly, half the other stuff we have no idea what exactly they are: JObject, what is returned by your GetResponse call. Thirdly, why are you preparing a byte array version of your...
19 May 2021 by Michael Waters
I need to dynamically load a .NET managed assembly into a Unix/Linux shared object that itself exports four functions is C. What I have tried: I have an existing code base written in C# for .NET 5/Core 3 that I need to dynamically load into a...
16 Oct 2021 by Daimel Luis Hernández
Hello, I have a console application created in c ++ that loads a dll, let's say target.dll, this library contains only one function What I have tried: void Print (char * text) { ����// Code in c ++ to print in console } but I need to inject my...
18 Oct 2021 by Daimel Luis Hernández
I already found the solution, using the DllExport library NuGet Gallery | DllExport 1.7.4[^] I hope someone is helpful
22 Jun 2013 by Pero Matić
A detailed analysis of how to inject the .NET runtime and arbitrary .NET assemblies into unmanaged and managed processes; and how to execute managed code within those processes.
2 Jan 2020 by Alexandre Bencz
DotNetPELib is a library which abstracts managed information such as namespaces, classes, fields, methods, and instructions. The information can then be used to generate assembly language source files, or PE executables or DLLs.
9 Nov 2010 by Simeon Sheye
Quality Gate One Studio is a testing framework that suggests a new approach to unit and integration testing.
23 Oct 2010 by Ahmed_Said
Creating a custom Jumplist with custom events and examining all of its features in Windows Forms 3.5
22 Dec 2012 by Amit Bezalel
Get simple debug info from a tray icon.