c++-cli

Attribute cannot be repeated in C++/CLI but OK in C#?

回眸只為那壹抹淺笑 提交于 2019-12-12 14:31:06
问题 I'm getting error C3095: 'Xunit::Extensions::InlineDataAttribute': attribute cannot be repeated in C++/CLI code but not C#. xUnit.net looks like the answer to my prayers - a modern unit test framework with GUI working with C++/CLI. However, using their approach to parameterised testing gives me the error C3095 as shown below. Any ideas? I'm using the latest xUnit.net 1.6 with Visual Studio 2008SP1. using namespace Xunit; using namespace Xunit::Extensions; public ref class

C++ to C# event handling

冷暖自知 提交于 2019-12-12 14:29:01
问题 So I've got my C# WinForm Application, from it I call my C++ CLI MFC dll library. But there are some events on my C++ library, even this events happens in native (non-CLI) part of this library. And I need to call some code from my C# application and get some data maybe right there on this event. so when this native function is called from client side : bool __stdcall ClassName::WorkQuery() { ...... switch(pp->code) { case READCOMPLEX: .......... I need to bring the Data from C# so I need to

Mixing managed/unmanaged C++?

北战南征 提交于 2019-12-12 13:34:03
问题 I have a library written in standard C++. I also have a .Net windows form app written in C# that utilizes the unmanaged library. I understand I can just use pinvoke, but my C++ is completely OO and I really wouldn't want to mess around with marshaling and such. Is there a way that I can just create a new managed C++ dll project, copy and paste my header and code files, and compile it and have access to all the classes? Or would I have to create some ref class in managed c++ and hook it up to

Marshal to std::string from System::String^ member of struct handle

爱⌒轻易说出口 提交于 2019-12-12 13:27:06
问题 I am trying to marshal to a std::string from a System::String^. Usually this can be done with the marshal_as<T> template i.e. System::String ^managedString = "test"; std::string stdString = marshal_as<std::string>(managedString); But if the String^ is part of a struct that is accessed by reference i.e. value struct SomeStruct { String ^managedString; }; auto structHandle = gcnew SomeStruct(); structHandle->managedString = "test"; std::string stdString = marshal_as<std::string>(structHandle-

How should multiple Fortran strings be passed to C?

回眸只為那壹抹淺笑 提交于 2019-12-12 12:49:10
问题 To pass a Fortran string to C, a hidden parameter is also passed with the variable's size. Here's a working fortran definition, and the C (actually C++/CLI) method: interface subroutine AppendExtension( + Filename) + bind(C, name="AppendExtension") character *1, intent(inout):: Filename end subroutine AppendExtension end interface and here's the C++/CLI that gets called: extern "C" { void __declspec(dllexport) __cdecl AppendExtension( char * name, int buffersize) { String^ clistr = gcnew

include dlls in visual studio c++ 2008

浪尽此生 提交于 2019-12-12 12:30:28
问题 Is there a way to include dlls in a project so that I don'thave to put those dlls in the same folder with my executable after compiling. This way I could just compile my project with them. Is this a possibility and if yes could someone guide me. My project is an opencv project and there are many dlls that I would have to include in the folder, and I don't know whether they are .NET assemblies or not, since I read an other post which said that it can be done with .NET assembly dlls. 回答1: You

C++/CLI: #pragma managed / unmanaged scope

喜欢而已 提交于 2019-12-12 12:17:26
问题 I have a mixed-mode DLL, and a .cpp file in it with both managed and unmanaged code. A simplified repro example looks like this: #include "stdafx.h" #pragma managed // Just for explicitness (doesn't influence results) #include <msclr\marshal.h> void Test() { System::String^ sName = ""; msclr::interop::marshal_context context; context.marshal_as<const TCHAR*>(sName); } //#pragma unmanaged // uncomment this line to get errors This code compiles successfully, however if I uncomment the last line

c++ cli interface event explicit implementation

霸气de小男生 提交于 2019-12-12 12:12:41
问题 I am trying to convert c# code into c++/cli. Everything went smoothly until i started translating interface event explicit implementations into c++/cli syntax. Let's say in c# i have this interface public interface Interface { public event MyEventHandler Event; } Which is implemented in Class in explicit way, so it doesn't conflict with another member by its name: public interface Class : Interface { event MyEventHandler Interface.Event; public event AnotherEventHandler Event; } I am trying

CLI/C++: void* to System::Object

我只是一个虾纸丫 提交于 2019-12-12 12:09:45
问题 This is a similar question to this SO post, which I have been unable to use to solve my problem. I have included some code here, which will hopefully help someone to bring home the message that the other posting was getting at. I want to write a CLI/C++ method that can take a void pointer as a parameter and return the managed object (whose type I know) that it points to. I have a managed struct: public ref struct ManagedStruct { double a; double b;}; The method I am trying to write, which

How do I debug Windows Forms Designer crashing?

自古美人都是妖i 提交于 2019-12-12 12:06:45
问题 I have a windows forms project. It has a main form derived from System::Windows::Forms::Form which I can open in designer without any problems. If I try and close designer though, it kills Visual Studio (v2008 with SP1). The form includes a tab control which has pages with various System::Windows::Forms::UserControl derived forms. So I'm guessing the fault lies somewhere in the main form or one of those sub-components. The problem is I don't know how I can narrow it down at all? I've tried