Click here to Skip to main content
15,901,373 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 Updated

Managed 

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...
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 3umphant
Found the solution public: property String^ default[String^] { virtual String^ get(String^ index) { return GetColumnError(index); } }
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 =...
18 Mar 2014 by Abhinav S
Yes. However, you can be calling unmanaged code in a console application.
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,...
30 Dec 2014 by Afzaal Ahmad Zeeshan
Do you even know what a mananged code is? The code that runs for the .NET framework is known as managed code. There are more than 20 lanugages that can be used to write applications on .NET framework, C++ is also one of them and you can write applications in C++ and they can be called managed...
23 Oct 2010 by Ahmed_Said
Creating a custom Jumplist with custom events and examining all of its features in Windows Forms 3.5
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...
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) { ...
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.
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...
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...
22 Dec 2012 by Amit Bezalel
Get simple debug info from a tray icon.
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...
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...
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...
13 Dec 2013 by CathalMF
Describes with an example of how you can call C#.NET methods from unmanaged C++ code.
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...
5 May 2015 by chandanadhikari
Hi,as i understand, basically your problem statement is:There is a project in Unmanaged C++. You wan to call the functions in this Project in your C# application.Here are the steps:It is common practice to write complex or time consuming algorithmic code in C++, to leverage the speed...
26 Feb 2011 by Close Network
Hi,I have a simple question. Suppose I have two classes like below.class Room{}class LivingRoom : Room{ int p1; public void Method() { }}And suppose I am creating a new instance of class LivingRoom in my main program and assigning it to...
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
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.
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.
25 Jun 2011 by dawmail333
Using my non-existent knowledge of C++ (hey, at least I know what a pointer is :P ), I managed to throw together some code samples to create a solution that will inject a DLL file into another program.Unfortunately, it's the DLL I'm INJECTING that's not working properly: it successfully...
9 May 2011 by Debojyoti Majumder
Try to use #pragma once in the header file MyInterface.h.That might solve the problem.
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!
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.
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 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
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
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...
19 Jul 2013 by Gaurav_Chhatbar
Object oriented implementation of basic language processing / parsing leveraging LINQ / PRISM / UnityContainer.
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...
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:...
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...
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...
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...
27 Aug 2011 by Juniad
Hi, I read the article regarding multiple forms on codeproject.com.The article was quite good, and i learnt how to call form2 from form1. But i want to know how to call form1 from form2 in visual C++.Net.Guide me asapRegardsJunaid
17 Nov 2014 by KarstenK
It is an easy task. Look at this code from Microsoft.You could ofcourse use your dll and function.
5 May 2015 by KarstenK
You created somehow a mess - now you got to cleanup. It is always a bad idea to use different languages and trying to mix them up in the end. 1. use classes or namespace to separate and cleanup your code.2. include the resulting C++ stuff in as little dll as possible and use them via C#....
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...
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...
19 May 2012 by Kitarolivier
Hello,I need to call a function which returns an array of pointer to structures :here is the c++ declaration :const VDXPluginInfo *const *VDXAPIENTRY VDGetPluginInfo();it returns an array of pointers to a VDXAPIENTRY, which is terminated by a pointer to zeroHow can I translate...
12 Jul 2015 by Kornfeld Eliyahu Peter
WinRT does support 3D via DirectX, just like WPF...http://video.ch9.ms/sessions/build/2012/3-112.pptx[^]
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= " ...
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.
18 Oct 2011 by luke2
Hi,I have a question regarding getting strings from unmanaged c++ code.In my unmanaged code I have a following declaration:__declspec(dllexport) bool A(const char*);I call this function from my managed C++ in the following way:String* args=...;char* str =...
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?
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...
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...
8 May 2013 by Mark Meyers
I am trying to go the opposite way of most articles I have found. I need to create an unmanaged, C++ DLL to serve as an entry into a C# DLL. The reason is that I need to expose functions to Firebird/Interbase as UDFs. I do not know C++ and am looking for assistance in creating a simple...
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...
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.
10 Oct 2022 by Mehul Donga
Handle managed (C#) event in managed (C++/CLI)
28 Jun 2016 by Member 12599256
Answer from Microsoft : https://support.microsoft.com/en-us/kb/3006861[^]
30 Dec 2018 by Member 14079943
shall i connect sqlserver from managed c++ What I have tried: shall i connect sqlserver from managed c++
3 Mar 2021 by Member 14649480
Hi, I have developed a c# dll that makes http reqest using System.Net namespace. If I call the dll methods from an c# programm everything workes fine but i need to use this dll from native c++ code. For this i used COM interop service. All goes...
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...
24 Jan 2012 by Michael Haephrati
To begin with you should change c++ into cp++ for(cp=0;cp
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...
5 Dec 2013 by Mihai Pruna
Basically I would like to be able to create a program that points at any static library (fed as a file parameter) and generates a series of functions and structures that can be used in C#Is this possible?
3 Jul 2012 by Mihai Vrinceanu
Compiler -> IR (intermediate representation) -> Optimizer -> Optimized Intermediate Representation -> Assembler -> Binary Code -> Linker -> Application Code.Native Application Code -> Native CPUManaged Application Code -> Virtual Machine with Logical CPU -> Native CPUShort...
7 Oct 2012 by Mike Hodgson
Hi,I'm wanting to use the MSScriptControl from C++ (Visual Studio 2012). When I call the AddObject in runtime I get a "Specified Cast Is Invalid" error.I have this is my AssemblyInfo.cpp:[assembly:ComVisible(true)];This is my BasicCommands.h:namespace BasicCommands{ ref class...
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#.
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 ?
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 =...
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,...
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...
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...
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...
7 Nov 2011 by OriginalGriff
dynamic_cast
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.
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...
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.
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...
30 Dec 2018 by Patrice T
Quote: shall i connect sqlserver from managed c++ Depends if you need to access an SQL database.
17 Apr 2023 by pdoxtader
Very fast image processing without use of unsafe code
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.
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...
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...
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...
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 =...
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
24 Jan 2012 by RedDk
#using using namespace System;int main(){ //Two arrays: __wchar_t and String array^ chararray3 = gcnew array(5); array^ strarray = gcnew array(5); //values into arrays chararray3[0] = L'\u2550'; chararray3[1] =...
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...
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.
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#[^].
19 Jun 2013 by Ron Beyer
Calling Managed Code from Unmanaged Code and vice-versa Article on CodeProject[^]
5 Dec 2013 by Ron Beyer
Why create one when it already exists, for free?tlbimp.exe[^]
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...
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;...
12 Oct 2011 by Sergey Alexandrovich Kryukov
They certainly can. You miss something.—SA
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...
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...
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...
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...