c++-cli

Any CPU dependent on C++/CLI dependent on native C dll (any cpu for c++/cli)

こ雲淡風輕ζ 提交于 2019-12-02 14:44:09
Here's my problem. I am wrapping a C dll in C#. To do this, I am first writing a C++/CLI wrapper. The native C library is linked to the C++/CLI wrapper. (Linker properties in C++/cli project). Here's how it is all organised now: - The native C .lib: both x86 and 64bit. 1 solution containing 2 projects: C++/CLI wrapper project to which is linked native C .lib C# project referencing C++/CLI project My problem comes from the fact that I need C# to target "Any CPU". But this option is not available in C++/CLI since it compiles directly to native code. My idea to solve this is: - Compile C++/CLI

Adding #pragma make_public(Type) not removing C3767 error

怎甘沉沦 提交于 2019-12-02 12:32:32
问题 I have an Assembly(A) which defines a Managed class which has a public constructor that takes two native types. I have access to the Header files and compiled lib files which contain the native types. I created a C++/CLI project and defined a ref class which contains a single public: static method that returns a public type defined in (A). When I try to contstruct by passing in a native type I receive the `C3767 'YourType::TypeB': Candidate function(s) not accessible. I've added #pragma make

Unicode string literals in C# vs C++/CLI

你说的曾经没有我的故事 提交于 2019-12-02 12:21:49
问题 C#: char z = '\u201D'; int i = (int)z; C++/CLI: wchar_t z = '\u201D'; int i = (int)z; In C# " i " becomes, just as I expect, 8221 ($201D). In C++/CLI on the other hand, it becomes 65428 ($FF94). Can some kind soul explain this to me? EDIT : Size of wchar_t can not be of issue here, because: C++/CLI: wchar_t z = (wchar_t)8221; int i = (int)z; Here too, i becomes 8221, so wchar_t is indeed up to the game of holding a 16-bit integer on my system. Ekeforshus 回答1: You want: wchar_t z = L'\x201D';

Linking error while in C++/CLI project while wrapping C++ shared library

坚强是说给别人听的谎言 提交于 2019-12-02 12:13:02
I am trying to wrap C++ library to that managed projects can use it. The third party library I am using is a shared library. It's meant to link on load time. I have header files, .lib file which is DLL import library and .DLL file. This is what I did so far:- 1. Created CLR project. 2. Added path for header file in C/C++->General->Additional Include Directories 3. Set 'Additional Library Directories' in Linker->General. 4. Added lib name in Linker->Input->Additional Dependencies After I do that, I get LNK2005 linking error followed by LNK1169. The only thing I did after creating the project is

Type visibilty for a header Share a header file shared between native and managed clients

牧云@^-^@ 提交于 2019-12-02 11:55:25
I have a header file that is included by both a native cpp file and a managed cpp file(compiled with /clr). It includes only native types, but I want to specify that the native types are visible outside the assembly (see http://msdn.microsoft.com/en-us/library/4dffacbw(VS.80).aspx ). Essentially, I want: public class NativeClass // The public makes this visible outside the assembly. { }; If I include this code from a native cpp, I get the following error: error C3381: 'NativeClass' : assembly access specifiers are only available in code compiled with a /clr option Attempted solution: I'm

WPF intercept clicks outside a modal window

别来无恙 提交于 2019-12-02 11:47:53
问题 Is it possible to check when the user has clicked outside a modal window? I'd like to somehow circumvent the modal logic because if the window isn't displayed as modal, it will not be shown on top of the active window, and, for now, this is the only way to display it correctly. I haven't found a proper way to do just that (since the "deactivate" event will no longer be triggered..) 回答1: Even if it's a modal window (displayed with ShowDialog() calls), one can add some even handlers to the

LPOVERLAPPED_COMPLETION_ROUTINE is incompatible with function

淺唱寂寞╮ 提交于 2019-12-02 09:34:39
I want to asynchronously write data to file using WriteFileEx from winapi , but I have a problem with callback. I'm getting follow error: an argument of type "void (*) (DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)" is incompatible with parameter of type "LPOVERLAPPED_COMPLETION_ROUTINE" What am I doing wrong? Here is code: // Callback void onWriteComplete( DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) { return; } BOOL writeToOutputFile(String ^outFileName, List<String ^> ^fileNames) { HANDLE hFile; char DataBuffer[] = "This is

Concurrent File write between processes

独自空忆成欢 提交于 2019-12-02 09:07:11
I need to write log data into a single file from different processes. I am using Windows Mutex which needs Common Language Runtime support for it. Mutex^ m = gcnew Mutex( false,"MyMutex" ); m->WaitOne(); //... File Open and Write .. m->ReleaseMutex() Do I really need to change from C++ to C++/CLI for synchronization? It is ok if the atomic is not used. But I need to know whether using this Mutex will slow down the performance compared to local mutex. Adding CLR support to your C++ application just to get the Mutex class is overkill. There are several options available to you to synchronize

Attempting to convert C++ into C# with interop

南楼画角 提交于 2019-12-02 08:40:24
I've got a program that calls to EGL in C++. I want to make the same call in C#, but there doesn't seem to be an equivalent concept in C#. I'm getting a read/write access denied error when the execution context enters the C++ EGL code. This is the code in the C++ program that I'm trying to convert to C#: PropertySet^ surfaceCreationProperties = ref new PropertySet(); surfaceCreationProperties->Insert(ref new String(EGLNativeWindowTypeProperty), somethingOtherThanAWindow); mEglSurface = eglCreateWindowSurface(mEglDisplay, config, reinterpret_cast<IInspectable*>(surfaceCreationProperties),

How do I forward declare a delegate in C++/CLI?

丶灬走出姿态 提交于 2019-12-02 07:52:09
问题 How? The following did not work: delegate MyDelegate; ref class MyDelegate; delegate void MyDelegate; The following works for declaration: public delegate void MyDelegate(Object ^sender, MyArgs ^args); But using it as a forward declaration gives me error C3756: 'MyNameSpace::MyDelegate': delegate definition conflicts with an existing symbol 回答1: This work's for me; stdafx.h: public delegate void Handler(bool isit); cli1.cpp: #include "stdafx.h" using namespace System; namespace MY { namespace