c++-cli

C++ syntax error : missing ';' before '<'

依然范特西╮ 提交于 2019-12-25 05:27:26
问题 Ehh, I'm having an issue which i don't understand... class ManagedGlobals { public: gcroot<Editor^> MainEditor; }; Why does my compiler give me: syntax error : missing ';' before '<' Why? 回答1: Did you do this? #include <vcclr.h> using namespace System; Here's a full example of using gcroot. 来源: https://stackoverflow.com/questions/11567792/c-syntax-error-missing-before

gcnew operator for generic type

孤街浪徒 提交于 2019-12-25 05:01:59
问题 I have the following simple class generic<typename T> where T:IDbConnection ref class CDbConnection { private: IDbConnection^m_db; ConnectionState^ m_originalConnState; public: CDbConnection(); bool Connect(String ^ connStr); bool Exists(int id); auto GetAllData(String^ tableStr); ~CDbConnection(); !CDbConnection(); }; and here is my constructor generic<typename T> CDbConnection<T>::CDbConnection() { m_db=gcnew T(); m_originalConnState=m_db->State; } But the compiler complains <1> the gcnew T

Thread freezing the application

夙愿已清 提交于 2019-12-25 04:43:15
问题 I'm designing an application which reads DICOM data sets and visualizes them with volume rendering techniques by using VTK library. Anyway, the problem I'm dealing is volume rendering is really CPU-bounded process. If I handle the volume rendering in a single threaded process, application (GUI) freezes and passes to "not responding" state. I have written another thread for volume rendering process. However GUI still freezes, here are the codes. private: System::Void volumeRenderButton_Click

visual c++ cURL webpage source to String^

可紊 提交于 2019-12-25 04:03:24
问题 Im' looking for solution how to read website to system::String^ i found curl to std::string idea but after converting linker has a few errors ;/ here is my code: using namespace std; string contents; size_t handle_data(void *ptr, size_t size, size_t nmemb, void *stream) { int numbytes = size*nmemb; // The data is not null-terminated, so get the last character, and replace // it with '\0'. char lastchar = *((char *) ptr + numbytes - 1); *((char *) ptr + numbytes - 1) = '\0'; contents.append(

Calling IOS::exception(…) causes EOF to throw InteropServices.SEHException from std::getline(…) in C++-CLI, why?

廉价感情. 提交于 2019-12-25 03:55:30
问题 I run the following function to load a file. It is being ported from CLI to standard C++ and exhibits unexpected behaviour when I attempt to specify that I would like to throw all exceptions except EOF. bool parseFile(ManagedClass *%parsedFileAsManagedObject, const string &fileName); std::string line; bool success = true; ifstream is(fileName.c_str()); //Unless I comment out the following line I get problems is.exceptions( ifstream::badbit | ifstream::failbit ); //do stuff try { while

Dynamically adding menuStrip items

牧云@^-^@ 提交于 2019-12-25 03:54:26
问题 so I have a problem with dynamically adding items to menuStrip. I mean I know how to add items to it, but I dont have any idea how to make Click handler to those dynamically added items. for(int i = 0; i < grupiuKiekis; i++) { row2 = mysql_fetch_row(result2); System::String^ grupesName = gcnew String(row2[1]); pasirinktiGrupęToolStripMenuItem->DropDownItems->Add(grupesName); } Please show me the right way to do it. 回答1: The Add method has several overloads. You could use the overload that

Visual C++ Error C2146

耗尽温柔 提交于 2019-12-25 03:28:24
问题 everyone, I was trying to compile a program using C++/CLI to check my stocks, but I ran into an error when I put the variable in the URL. Can anyone help me, please? private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this->webBrowser1->Navigate("http://finance.yahoo.com/echarts?s="num".HK+Interactive#chart1:symbol="num".hk;range=1d;indicator=volume;charttype=line;crosshair=on;ohlcvalues=0;logscale=on;source=undefined"); } Oh, and by the way, this code is from

Visual Studio Configuration Manager x64 only option

亡梦爱人 提交于 2019-12-25 03:08:59
问题 I seem to have completely the *emphasized text*opposite*emphasized text* problem to everyone else... I'm trying to have my program (C++/CLI - Visual Studio 2010) run on any machine - but it's only working on 64 bit machines... I checked my Configuration Manager and when I try and choose a new platform, "x64" is the only one that exists? There is no other option - and I'm a bit stuck for ideas :( 回答1: In the configuration manager, for each project it lists the Platform (x86, x64, etc.). Just

Passing an array of interfaces from C# to C++/CLI

只谈情不闲聊 提交于 2019-12-25 02:46:19
问题 I am trying to pass an array of interfaces from C# to C++/CLI. Here is the code: // *** SafeArrayTesting_PlusPlus.cpp *** #include "stdafx.h" #include <comdef.h> using namespace System; using namespace System::Runtime::InteropServices; namespace SafeArrayTesting_PlusPlus { public ref class MyCppClass { public: MyCppClass(); ~MyCppClass(); void SetMyInterfaces( array<SafeArrayTesting_Sharp::MyInterface^>^ myInterfaces); }; MyCppClass::MyCppClass(){} MyCppClass::~MyCppClass(){} void MyCppClass:

C++/CLI — Access Structure Member

人走茶凉 提交于 2019-12-25 02:31:53
问题 I am trying to access a .NET structure member but compilation fails even for this simple example: .h: using namespace System::Drawing; namespace MyNamespace{ public ref class MyClass{ public: MyClass(); static const System::Drawing::Size MinimumSize = System::Drawing::Size(20,20); } } .cpp: #include "MyInclude.h" MyClass::MyClass(){ int i = MinimumSize.Width; // ..... } The statement which assigns the MinimumSize.Width to the local variable i fails to compile: "No instance of function "System