c++-cli

C++ CLI Correct way to use #pragma managed / unmanaged

ⅰ亾dé卋堺 提交于 2020-01-21 02:57:05
问题 I'm writing a C++ / CLI application, but I want most of the code in my C++ DLL to run natively (i.e. not managed). I have only got a single CLI class in the module, the other files are all native C++. So, what is the best way of ensuring that those native classes are run... Well, natively? Should I: A) Add #pragma unmanaged to the top of every native class B) Just add #pragma unmanaged before the includes in my single CLI class C) Something else? Thanks 回答1: You don't have to jump through

How to get MFC serialization going without a CWinApp-derived class?

送分小仙女□ 提交于 2020-01-17 06:04:19
问题 I am writing a C++/CLI wrapper for an old MFC application, so far i have been able to read most of the data and convert the same into C# readable format. As of now i am only struggling with reading data and am worried will writing data back to old MFC code affect serialization ? Can you guys share/mention any other risks i might face while writing C++/CLI wrapper for MFC code ? Thanks for your inputs. this question is a continuation of "Redirecting data from MFC CArchive to boost::archive:

SimpleBlobDetector detect Exception Thrown

一个人想着一个人 提交于 2020-01-16 14:13:48
问题 I am using SimpleBlobDetector, of course to detect circles, in images grabbed from a camera and have undergone OpenCV color and morphological filters. I am receiving an Exception thrown at 0x000... (opencv_imgproc249.dll) in .exe: Access violation reading location 0x000... I am receiving this error on the line containing: d.detect(canny, keypoints); Here is a sample of my code: std::vector<KeyPoint> keypoints; SimpleBlobDetector d(params); d.detect(canny, keypoints); drawKeypoints(im,

SimpleBlobDetector detect Exception Thrown

末鹿安然 提交于 2020-01-16 14:13:46
问题 I am using SimpleBlobDetector, of course to detect circles, in images grabbed from a camera and have undergone OpenCV color and morphological filters. I am receiving an Exception thrown at 0x000... (opencv_imgproc249.dll) in .exe: Access violation reading location 0x000... I am receiving this error on the line containing: d.detect(canny, keypoints); Here is a sample of my code: std::vector<KeyPoint> keypoints; SimpleBlobDetector d(params); d.detect(canny, keypoints); drawKeypoints(im,

SimpleBlobDetector detect Exception Thrown

一曲冷凌霜 提交于 2020-01-16 14:13:06
问题 I am using SimpleBlobDetector, of course to detect circles, in images grabbed from a camera and have undergone OpenCV color and morphological filters. I am receiving an Exception thrown at 0x000... (opencv_imgproc249.dll) in .exe: Access violation reading location 0x000... I am receiving this error on the line containing: d.detect(canny, keypoints); Here is a sample of my code: std::vector<KeyPoint> keypoints; SimpleBlobDetector d(params); d.detect(canny, keypoints); drawKeypoints(im,

C++/CLI: wrapping the same unmanaged object in multiple managed objects

老子叫甜甜 提交于 2020-01-16 08:45:10
问题 I am developing a library which has two layers, unmanaged (C++) and managed (C++/CLI). The unmanaged layer contains the logics and the computation algorithms, while the managed layer provides interface and visualisation to a .NET-based host application. A class in the managed layer wraps its class counterpart in the unmanaged layer, e.g. ManagedA wraps UnmanagedA and ManagedB wraps UnmanagedB. Classes in the unmanaged layer have query methods, suppose UnmanagedA::B() returns an instance of

Snap7 writing to a S7-1200 PLC

别说谁变了你拦得住时间么 提交于 2020-01-16 04:08:17
问题 I'm trying to write something to my Siemens PLC with a C++/CLI application. Reading is ok (except the first time it reads it gives odd values). But writing is doing something completely different then what I want. below you can find the code: private: void WriteSiemensDB() { byte* buffer; if (ConnectToSiemensPLC()) //Check if you are connected to PLC { String^ msg; int DBNumber = 2; bool NDR; //Getting the values 1 time so buffer has a value buffer = sPLC->ReadDB(DBNumber); //give variables a

Migrating C++CLI wrapper from .NET 4.0 to 4.5 cause winsock error on Windows Server 2012 R2

喜你入骨 提交于 2020-01-15 23:55:47
问题 I have build a C++ CLI wrapper for a communication middleware we use. The wrapper has been in .NET 4.5 and works fine in Windows 7 and Windows Server 2008 R2. But in Windows Server 2012 R2 it crashes with an "Access violation" error in mswsock.dll The interesting part is that if I build the wrapper and test application to target .NET 4.0 it works. But when I re-target them to .NET 4.5.x it triggers the exception. I've tried to investigate security, strong naming, hot-fix'ing .NET, but to no

OpenCV memory leak issue

a 夏天 提交于 2020-01-15 12:14:13
问题 This function of drawItem is called multiple times through a loop, I'm facing a memory leak issue everytime it is called. I'm thinking that the problem is due to the resizeImage() function, but I can't seem to pinpoint the problem, this is C++\CLI with OpenCV library. drawItem() { imgItem = resizeImage(imgItem, newItemWidth, newItemHeight, false); imgMask = resizeImage(imgMask, newItemWidth, newItemHeight, false); cvSetImageROI(image3, cvRect(x1,y1,newItemWidth, newItemHeight)); cvCopy

Inheritance between clr project dlls

五迷三道 提交于 2020-01-15 11:44:07
问题 I have an abstract base class which is written with c++/cli. This class is located in a project. And i have other projects which inherit the abtract base class. So, the structure is like the following. Base Project: public ref class Base abstract { // implementation virtual CommonFunc(); }; public delegate void Foo(); Derived Project A: public ref class A : public Base { // implementation }; Derived Project B: public ref class B : public Base { // implementation }; And, so on. I can call both