unmanaged

Performance of Managed C++ Vs UnManaged/native C++

不羁岁月 提交于 2019-12-03 03:45:21
I am writing a very high performance application that handles and processes hundreds of events every millisecond. Is Unmanaged C++ faster than managed c++? and why? Managed C++ deals with CLR instead of OS and CLR takes care of memory management, which simplifies the code and is probably also more efficient than code written by "a programmer" in unmanaged C++? or there is some other reason? When using managed, how can one then avoid dynamic memory allocation, which causes a performance hit, if it is all transparent to the programmer and handled by CLR? So coming back to my question, Is managed

Access X509 Certificate store with unmanaged C++

只谈情不闲聊 提交于 2019-12-02 04:28:38
问题 Does anyone know how I would do the equivalent of the below C# code using unmanaged C++ i.e. query a certificate from the X509 certificate store by thumbprint? var store = new X509Store(StoreName.My, StoreLocation.LocalMachine); store.Open(OpenFlags.ReadOnly); var allCerts = store.Certificates; foreach (var certificate in from X509Certificate2 certificate in allCerts where certificate.Thumbprint != null && certificate.Thumbprint.Equals(thumbprint, StringComparison.OrdinalIgnoreCase) select

get pointer on byte array from unmanaged c++ dll in c#

家住魔仙堡 提交于 2019-12-02 02:30:42
in c++ I have such function extern "C" _declspec(dllexport) uint8* bufferOperations(uint8* incoming, int size) I am trying to call it from c# like this [DllImport("MagicLib.DLL", CallingConvention = CallingConvention.Cdecl)] //[return: MarshalAs(UnmanagedType.ByValArray)]//, ArraySubType=UnmanagedType.SysUInt)] public static extern byte[] bufferOperations(byte[] incoming, int size); But I get the Cannot marshal 'return value': Invalid managed/unmanaged type combination ((( The question is - how to marshal this correctly? Thanks for reading my question byte[] is a .Net array type with known

MFC Dll with COM Interface

让人想犯罪 __ 提交于 2019-12-02 02:15:35
问题 I am pretty new to managed/unmanaged interoperability and COM concepts. I received a suggestion of using COM Interop, for using my existing MFC code in C#. But the problem for me is, i have a MFC Dll which is not a valid COM component. How can I make this MFC DLLs to have COM-accessible interfaces ready for use in .NET? 回答1: From thread Loading MFC DLL in C# Windows Application To access native code from C# you have a few choices. Most directly, you can use DllImportAttribute to describe your

MFC Dll with COM Interface

北城以北 提交于 2019-12-02 01:42:29
I am pretty new to managed/unmanaged interoperability and COM concepts. I received a suggestion of using COM Interop, for using my existing MFC code in C#. But the problem for me is, i have a MFC Dll which is not a valid COM component. How can I make this MFC DLLs to have COM-accessible interfaces ready for use in .NET? From thread Loading MFC DLL in C# Windows Application To access native code from C# you have a few choices. Most directly, you can use DllImportAttribute to describe your DLL's entry points in C# terms so that they can be called via P/Invoke. They'll look like static methods to

Which managed classes in .NET Framework allocate (or use) unmanaged memory?

耗尽温柔 提交于 2019-12-01 17:24:33
Is there a known (documented) set of .NET types that allocate memory in the unmanaged portion of the process' memory? For example, Microsoft documents that the WPF infrastructure allocated unmanaged memory for its retained rendering model in order to optimize performance. Are there other such portions of the .NET framework that utilize large amounts of unmanaged memory? If it implements IDisposable there is a very good chance it owns unmanaged data, or it's owning a managed class that ultimately owns unmanaged data. If it has Finalize() , it's sign that it directly owns unmanaged data. As a

MSBuild Managed vs Unmanaged property

喜欢而已 提交于 2019-12-01 17:09:56
问题 Is there a way in MSBuild logic to determine if I am running managed vs unmanaged code? Not C++ vs C#, but just managed vs unmanaged? I'd like to set some properties (usually just version information) differently depending on whether the code is managed or unmanaged. 回答1: There are normally two things that change in a vcxproj file for managed complation (afaik, at least that's how we have it in our master c++/cli property sheet used for all cli projects: the CLRSupport property is set to true

Which managed classes in .NET Framework allocate (or use) unmanaged memory?

末鹿安然 提交于 2019-12-01 16:51:12
问题 Is there a known (documented) set of .NET types that allocate memory in the unmanaged portion of the process' memory? For example, Microsoft documents that the WPF infrastructure allocated unmanaged memory for its retained rendering model in order to optimize performance. Are there other such portions of the .NET framework that utilize large amounts of unmanaged memory? 回答1: If it implements IDisposable there is a very good chance it owns unmanaged data, or it's owning a managed class that

Managing destructors of managed (C#) and unmanaged (C++) objects

本秂侑毒 提交于 2019-12-01 06:35:43
I have a managed object in a c# dll that maintains an anonymous integer handle to an unmanaged object in a c++ dll. Inside the c++ dll, the anonymous integer is used in an std::map to retrieve an unmanaged c++ object. Through this mechanism, I can maintain a loose association between a managed and unmanaged object using an anonymous integer handle. In the finalize method (destructor) of the managed object I have a call into the unmanaged dll to delete the unmanaged object. All is well as the c# program runs, but I have a problem when the program exits. Becuase I have no control on the order of

Pass Managed Function Pointer As Unmanaged Callback

烈酒焚心 提交于 2019-12-01 06:35:07
I am attempting to pass a managed function pointer void (*)(void *) to my unmanaged library. My unmanaged library calls this callback with a pointer to a frame of data protected by a CriticalSection. While the managed callback is running, nothing else can modify the frame of data due to the Critical Section. However, I am getting Access Violations and Heap Corruptions just by entering the callback. EDIT : I forgot to mention. The StartStreaming() steals the thread it manages. Furthermore, it creates a separate thread for dispatching new data to the given callback. The callback is called in