c++-cli

Calling C++/CLI delete on C# object

大憨熊 提交于 2020-01-11 00:20:14
问题 I'm in the middle of converting some code from C++/CLI to C#. One of the objects has a destructor in the C++/CLI version. Some other C++/CLI code calls "delete" on this object after use. Which method do I need to implement in the C# version of this object so those "delete"s continue to function the same (IDisposable.Dispose, the finalizer, or something else that I'm missing)? 回答1: I would say the IDisposable interface is what you look for if you need deterministic disposal of resources. This

Windows Phone 7 and native C++/CLI

喜夏-厌秋 提交于 2020-01-09 03:08:11
问题 Microsoft recently released tools and documentation for its new Phone 7 platform, which to the dismay of those who have a big C++ codebase (like me) doesn't support native development anymore. Although I've found speculation about this decision being reversed, I doubt it. So I was thinking how viable would be to make this codebase available to Phone 7 by adapting it to compile under C++/CLI. Of course the user interface parts couldn't be ported, but I'm not sure about the rest. Anyone had a

VS2015: Migrated project compiles, but won't run (“Debug Assertion Failed!”)

帅比萌擦擦* 提交于 2020-01-07 06:55:22
问题 I have a program that was original compiled in VS2013. Now that I have VS2015 installed, I have been having issues even getting my application to compile. It is written in C++/CLI. It originally targeted the v120_xp toolset. I tried compiling with that targeted toolset (along with all C++ libraries my program utilizes, which are GraphicsMagick and libsquish). It wouldn't even compile if it targeted that toolset. So I tried targeting v140_xp (a few of the users of my program still use Windows

How can I boost::bind to a member of a managed class which passes and returns a std::string?

喜你入骨 提交于 2020-01-07 03:36:09
问题 I'm trying to do something very similar to this but I'm struggling to pass the string to/from the callback. This is a pared down version of the code I'm trying to run: using namespace System; using namespace System::Runtime::InteropServices; #pragma unmanaged // The unmanaged boost function prototype the native library wants to bind to typedef boost::function<std::string(const std::string&)> MyNativeCallback; // The unmanaged library I'm trying to wrap class MyUnmanagedClass { public:

Why don't I get code coverage results for C++/CLI project in Visual Studio 2010?

我与影子孤独终老i 提交于 2020-01-06 16:22:20
问题 I've recently upgrade my solution to Visual Studio 2010. I have 4 projects I want to cover using unit tests - 3 C# and 1 C++/CLI. I get coverage for the C# projects but not for the C++/CLI project. I did get for all of them in Visual Studio 2008. I've configured the assemblies using testrunconfig -> Data and Diagnostics -> Code Coverage -> Configure. Why don't I get code coverage result for the C++/CLI project? 回答1: I've found out what was wrong. It appears that the upgrade from Visual Studio

Why don't I get code coverage results for C++/CLI project in Visual Studio 2010?

非 Y 不嫁゛ 提交于 2020-01-06 16:22:06
问题 I've recently upgrade my solution to Visual Studio 2010. I have 4 projects I want to cover using unit tests - 3 C# and 1 C++/CLI. I get coverage for the C# projects but not for the C++/CLI project. I did get for all of them in Visual Studio 2008. I've configured the assemblies using testrunconfig -> Data and Diagnostics -> Code Coverage -> Configure. Why don't I get code coverage result for the C++/CLI project? 回答1: I've found out what was wrong. It appears that the upgrade from Visual Studio

Why don't I get code coverage results for C++/CLI project in Visual Studio 2010?

馋奶兔 提交于 2020-01-06 16:22:02
问题 I've recently upgrade my solution to Visual Studio 2010. I have 4 projects I want to cover using unit tests - 3 C# and 1 C++/CLI. I get coverage for the C# projects but not for the C++/CLI project. I did get for all of them in Visual Studio 2008. I've configured the assemblies using testrunconfig -> Data and Diagnostics -> Code Coverage -> Configure. Why don't I get code coverage result for the C++/CLI project? 回答1: I've found out what was wrong. It appears that the upgrade from Visual Studio

Converting managed System::String to std::string in C++/CLI [duplicate]

我的梦境 提交于 2020-01-06 14:53:28
问题 This question already has answers here : C++/CLI Converting from System::String^ to std::string (10 answers) Closed 6 years ago . I am having problem with converting managed System::String to std::string in C++/CLI. This code does not work, I can't understand why: string SolvingUnitWrapper::getName(String ^name) { pin_ptr<const wchar_t> wstr = PtrToStringChars(name); ostringstream oss; oss << wstr; return oss.str(); } Thanks 回答1: try this: std::string managedStrToNative(System::String^ sysstr

How to get Process object of already running process?

ⅰ亾dé卋堺 提交于 2020-01-06 14:07:44
问题 I want a create a C++ program that can find an already running process and then redirect its Standard Output to my own stream for re-direction. I can find countless examples on how to start a new process but I want to try and do something like: Process^ proc = new Process(); proc->Attach("notepad.exe"); And then have control over the already running notepad.exe process.. Is this possible? If not then I guess I can find a way to start the process from within my application, however then my

CA1047 'Make member raise private, public, or internal' and C++/CLI events

99封情书 提交于 2020-01-06 08:27:09
问题 When I declare a public event in a sealed C++/CLI class, I get Code Analysis warning CA1047. The warning seems to come from auto-generated protected member functions. How can I fix this warning? Here's an example. This code ref class Test sealed { public: event EventHandler^ blah; }; generates: warning: CA1047 : Microsoft.Design : Make member 'Test::blah::raise(Object^, EventArgs^)' private, public, or internal 回答1: I'll document the question better. This code ref class Test sealed { public: