c++-cli

Reserved class name Visual C++

ぃ、小莉子 提交于 2019-12-23 10:17:02
问题 I want to create in my project class "Screen", "Graphics", "Font" and "Environment", but when I type these names and hit enter I get message: "Screen" is reserved class name or "Environment" is reserved class name. I don't want to make CScreen or ScreenC or something like that :/ I have Visual Stuido 2010. Is there any way to fix this ? 回答1: I think using namespace is the answer. 回答2: This is a bug in Visual Studio. There are a number of names that Microsoft's VS 2010 product believes are

Literal field versus constant variable in C++/CLI

笑着哭i 提交于 2019-12-23 10:09:19
问题 I'm going over some C++/CLI material and I've come across the concept of a literal field: literal int inchesPerFoot = 12; Is this preferable to a const because a const FIELD can't exist because a field cannot initialize itself...so: class aClass { private: const int aConstant = 1; // Syntax error. ... }; Thanks, Scott 回答1: A literal field is used for compile-time constants. It is associated with the class (similar to a "static const" field). In your example aConstant is a non-static const (an

Mixed C++/CLI TypeLoadException Internal limitation: too many fields

寵の児 提交于 2019-12-23 09:24:45
问题 On a quest to migrate some new UI into Managed/C# land, I have recently turned on Common Language Runtime Support (/clr) on a large legacy project, which uses MFC in a Shared DLL and relies on about a dozen other projects within our overall solution. This project is the core of our application, and would drive any managed UI code that is produced (hence the need to turn on clr support for interop). After fixing a ton of little niggly errors and warnings, I finally managed to get the

What does ^ after a type mean in c++?

拈花ヽ惹草 提交于 2019-12-23 08:58:02
问题 I have some c++ code with function return types declared as string^ or IEnumerable<String^>^ , what does that mean? edits: c#->c++/cli 回答1: It doesn't mean anything in C#. You're looking at source code for C++/CLI, not C#. See http://en.wikipedia.org/wiki/C%2B%2B/CLI for a brief introduction. The carat symbol basically means "this is a GC-tracked reference". 回答2: It seems like managed C++, not C#. ^ means managed reference type. 回答3: Nothing. It is not valid there in C++. It's a "managed

Why do I get error C3851 (a universal-character-name cannot designate a character in the basic character set)?

不羁岁月 提交于 2019-12-23 05:05:55
问题 I've been trying to translate an example whitespace remover from here on SO to run in a C++-cli project. The following looks fine as far as intellisense is concerned: static String^ TrimAllWithInplaceCharArray(String^ str) { unsigned int len = str->Length; array<wchar_t, 1>^ src = str->ToCharArray(); int dstIdx = 0; for (unsigned int i = 0; i < len; i++) { wchar_t ch = src[i]; switch (ch) { case L'\u0020': case L'\u00A0': case L'\u1680': case L'\u2000': case L'\u2001': case L'\u2002': case L'

Calling Java Methods from Visual C/C++ using C++/CLI

空扰寡人 提交于 2019-12-23 03:29:41
问题 I'm getting a "error LNK1104: cannot open file {path}\jvm.lib" when trying tocompile a VS C++/CLI (managed) project. It's very simple and my goal is to call some Java methods in pre-existing java libs - here is the code I'm using: // This is the main DLL file. #include "stdafx.h" #include <jni_md.h> #include <jni.h> #include "JBridge.h" #pragma once using namespace System; namespace JBridge { public ref class JniBridge { // TODO: Add your methods for this class here. public: void

C++/CLI : How to declare template array as method parameters

。_饼干妹妹 提交于 2019-12-23 03:12:48
问题 I am a newbie to C++/CLI. What is the equivalent of the following C# code in managed C++/CLI for both the header and source file? public static bool ArrayEquals<T>(T[] a, T[] b) { return true; } 回答1: Here is the content for the source file: public: generic <typename T> static bool ArrayEquals(array<T>^ a, array<T>^ b) { return true; } 回答2: I tried the following and kept getting linker errors. Now I know, the keyword generic should be used instead. Thanks Laurent! :) template<typename T> bool

How can we share the data using shared memory segment with “Object” between two managed processes?

南笙酒味 提交于 2019-12-23 01:16:20
问题 How can I share the data between two managed processes using shared memory segments? I am using "object" inside C++/CLI code to share the data with some other part of memory in the other process. I am using following code segment. #define BUFFER_SIZE 32768 #pragma data_seg (".SHAREDMEMORY") bool _Locked = false; bool _Initialized = false; unsigned char[10000] data = NULL; #pragma data_seg() #pragma comment(linker,"/SECTION:.SHAREDMEMORY,RWS") but I need it to be: #pragma data_seg ("

Weird scrollbar UI in hosted WPF composite control

坚强是说给别人听的谎言 提交于 2019-12-22 20:33:12
问题 My windows forms application hosts AvalonEdit (the composite WPF control in question) in one of its forms to cater to its text editing requirements. Here's the code I use: WPFHost = gcnew ElementHost(); TextField = gcnew AvalonEdit::TextEditor(); WPFHost->Dock = DockStyle::Fill; WPFHost->Child = TextField; TextField->Options->AllowScrollBelowDocument = false; TextField->Options->EnableEmailHyperlinks = false; TextField->Options->EnableHyperlinks = true; TextField->Options-

VS 2012 Debugger, modules loaded twice, breakpoint couldn't be hit

♀尐吖头ヾ 提交于 2019-12-22 17:44:22
问题 I have a Visual Studio 2012 solution which contains two projects, 1st is C++/CLI wrapper and the 2nd is C# , where I use the wrapped dll. Both projects are in 32 bit debug mode. In C# project Enable native code debugging option is enabled. In C++/CLI debugging mode is set to mixed . The problem is that in both projects the breakpoints can't be hit. I followed advices from here and here but without luck. The most interesting thing, that bot projects are loaded twice, the locations are the same