c++-cli

Calling C code from managed code

廉价感情. 提交于 2019-12-06 05:45:49
问题 I currently have a C function that I'd like to use in .NET (C#). I can see two ways of achieving this: Compiling it (I think this is possible) with /clr on VC++.NET, having implemented "façade" managed methods that call the C code. Compiling the C code as a DLL and then making API calls. What do you find best? How to do the first of them? Update As requested, here is the (only) function I need to call from my managed code: int new_game(double* params1, double* params2); Just one more question

What is the alternative to futures and promises in managed C++

旧时模样 提交于 2019-12-06 05:27:07
问题 When compiling managed C++ code with the /clr flag, the compiler does not allow the include. I am trying to port my unmanaged C++ code into a managed C++ environment. I see that C# has the alternatives Task and TaskCompletionSource to replace futures and promises but I do not see these options available in managed C++. I need to perform interop with some C++ unmanaged libraries so I cannot switch to C# completely. I still need a C++ layer in between. How can I achieve future/promise

Why do we see a ModuleLoadExceptionHandlerException when unit testing

感情迁移 提交于 2019-12-06 05:16:32
问题 We have a mixed mode assembly that contains both VC++ (using MFC) and C++/CLI classes. It is an MFC Extension dll and is loaded into our MFC executable at runtime and all works well. When we come to unit test the unmanaged classes in there from another C++/CLI assembly, we see the following exception everytime we try to create an instance (via new) of an unmanaged class: Exception System.TypeInitializationException: The type initializer for '<Module>' threw an exception. --->

Silverlight and C++ or C++ to C# ongoing code conversion?

橙三吉。 提交于 2019-12-06 04:37:56
I am working on a drawing-based product where I want to produce versions for iPhone, desktop OS/X, Windows Tablets, Silveright-based browser, Windows Mobile, and Windows in that order of priority. For GUI portability, the classic answer is to keep the core in C++ and use Cocoa/Objective-C or WPF/C# thin layers. However, Silverlight complicates the choices. I wouldn't have any problem migrating my code into C++/CLI and maintaining a dual code base (with some macros to fake the C++/CLI contextual keywords and some judicial search and replace for ^ and %). From what I've been able to find so far

Passing Unmanaged pointers in C++/CLI

别等时光非礼了梦想. 提交于 2019-12-06 03:52:34
问题 I'm creating a C++/CLI wrapper DLL that depends on numerous C++ static libraries. Some of the function calls expect unmanaged pointers to be passed in. How do i pass them properly? Also, other functions expect a "this pointer" to be passed in as a void*. What's the right way to pass "this"? Here's my class definition... public ref class RTPClient { public: RTPClient(); ~RTPClient(); bool Connect(); void Disconnect(); private: CIsmaClient* mClient; }; Here's my usage where the pointers in

Can C++/CLI .NET use resource .resx files for localization?

拟墨画扇 提交于 2019-12-06 03:49:52
I am trying to localize a managed C++ .NET DLL for multiple languages. The forms are easy enough because they operate just like the other languages and create multiple .resx files. I cannot find any examples of localizing embedded strings in managed C++, other than to use .RC string tables in the traditional C++ way. Is there any way to use .resx resource files to facilitate use with resource editors like Zeta , etc? Create a separate resources file in managed C++ containing all the error messages of the application. To do that, right-click on your managed C++ project in the solution explorer

Is it possible to run unmanaged C++ normally from a managed C++/CLI project?

戏子无情 提交于 2019-12-06 03:34:28
问题 I'm in the process of wrapping a pure unmanaged VC++ 9 project in C++/CLI in order to use it plainly from a .NET app. I know how to write the wrappers, and that unmanaged code can be executed from .NET, but what I can't quite wrap my head around: The unmanaged lib is a very complex C++ library and uses a lot of inlining and other features, so I cannot compile this into the /clr -marked managed DLL. I need to compile this into a seperate DLL using the normal VC++ compiler. How do I export

C++/CLI or C# for creating fast, modern and responsive GUI on Windows [closed]

ε祈祈猫儿з 提交于 2019-12-06 02:56:31
Currently I am split between these two languages. I'm almost halfway through programming my current application which needs to be very fast. It calculates insulated glass structures of any kind in multiple load-conditions. I just do not know if its the right choice to write it in C++/CLI. On the internet for example I never even read the name "C++/CLI" but everyone advises to learn C#. What are really the downsides of C++/CLI ? I have gathered from my reading that it is doomed to be deprecated in the next few years. Is this true? And if there are some, are they so bad it is really necessary to

Does C++/CLI event have any listeners?

十年热恋 提交于 2019-12-06 02:10:43
问题 In C# I can check if an event has any listeners: C# Example: public static event EventHandler OnClick; if (OnClick != null) OnClick(null, new EventArgs() ); In C++/CLI checking if the event is null is not necessary. C++/CLI Example: delegate void ClickDelegate( Object^ sender, MyEventArgs^ e ); event ClickDelegate^ OnClick; OnClick (sender, args); BUT, in the project I am working on, I don’t want to construct the MyEventArgs object if there are no listeners. How do I find out if OnClick has

Mixing MFC and WPF: Modal Dialogs

我怕爱的太早我们不能终老 提交于 2019-12-06 01:55:46
I'm adding C# WPF dialogs to an existing C++ MFC app, using a C++/CLI interface layer. I've got things working, except I'm having a problem with modality. For example: MFC app shows a WPF dialog using ShowDialog. Works as expected. That WPF dialog shows a MFC dialog using DoModal. The WPF dialog is hidden behind the base C++ app, and is not disabled unless I manually change IsEnabled. Not ideal, but it works. Now, that MFC dialog is closed. Now for some reason the base MFC app is enabled, when it should still be disabled due to the WPF dialog not having been closed. That's bad, as it now