Questions tagged [c++-cli]
C++/CLI is based on C++, modified to allow compilation of a mixture of native code and code for Microsoft's Common Language Infrastructure (CLI). It replaces Microsoft's Managed Extensions for C++, which aimed for stronger C++ conformance.
6,100
questions
0
votes
0
answers
30
views
libcurl is apparently crashing the application
Config:
Windows 11 x64
Visual Studio Project: CLR Empty Project (.NET Framework)
.NET Framework: 4.6.2
libcurl: curl-7.83.1 windows build (libcurl-vc-x86-release-static-ipv6-sspi-schannel)
Project ...
0
votes
1
answer
28
views
Visual studio add project reference with lib file
It looks like there has been some work done to add support for visual studio c++ project to project references.
https://developercommunity.visualstudio.com/t/MsBuild-to-resolve-and-copy-ProjectRefer/...
-2
votes
0
answers
47
views
Cross Platform dotnet 6 and C++
I have an existing C++/CLI dll that I use in a .NET framework project. The .NET project uses a lot of functionality in other shared libraries (all others are also .net). I would like to publish this ...
-1
votes
1
answer
21
views
In C++ CLI, how to use/declare a static int array accessible to all functions in the source file?
In C++/CLI, how to declare the C equivalent of "static int array[400]" where array is accessible to all functions in the source file -- without getting the error "a member of a managed ...
-4
votes
0
answers
28
views
I am new to C++ pointers, could anyone tell me how to correct this problem? [duplicate]
System::String stringA = "", stringB = "";
System::String^ pStringA = stringA^, pStringB = stringB^;
FunctionName(pStringA , pStringB);
The variable names are changed, but ...
-3
votes
0
answers
71
views
Is it possible to Static Link with CLR App ( Basically run .NET C++ without having to install VSRedistributables, but including them to the EXE )
Hello there. Before starting to explain my needs, i have to say that i already did read similar questions / threads, without finding a solution to my problem ( On SO but also forums... ).
That being ...
1
vote
2
answers
42
views
How to view a System::String with OutputDebugString?
I am trying to debug a value that is System::String. As I am using Visual Studio, I would normally use OutputDebugString or its variants to see the strings, but System::String aren't natively ...
-1
votes
0
answers
30
views
Warning 4793 (function compiled as native) when using Gmock 1.11 inside a CLR enabled test project
Am using VS2017, I have a C++/CLI CLR enabled test project that depends on Gmock v1.11 as a nuget dependency.
The act of adding the gmock nuget package means that gmock-all.cc and gtest-all.cc, ...
2
votes
1
answer
68
views
In C++/CLI, how to copy a char * to a System::String (not a C++ std::string)?
Though I know C well, I'm having trouble with copying a char array to a System::String (not a C++ std::string) in C++/CLI.
I'm using (for the first time) Visual Studio with its drop-and-drag form ...
-3
votes
0
answers
24
views
LNK2028 error when compiling C++ CLR Class Library
I am currently working on a C++ CLR Class Library for use in C# WPF. Basically, I tell the DLL to render OpenGL to a C# WPF window. However, whenever I try to compile the C++ CLR project I get many ...
-1
votes
0
answers
21
views
Exposing AssemblyResolve to native c++ code
I am trying to setup AssemblyResolve in a c++/cli dll.
If I have the following header:
namespace AssemblyInitNamespace
{
ref class AssemblyInit
{
public:
static void ...
-2
votes
0
answers
32
views
C++ (CLR) tooltip at screen x, y coords
Using Visual Studio 2019, in a windows C++ CLR project I tryed (with no success) to create a tooltip to be displayed always on top at 0,0 coordinates of the screen.
Based on the working tooltip code ...
-1
votes
1
answer
45
views
C# .Net6 - C++/CLI Nuget Package Fails
I am having problems creating a Nuget package for my C++/CLI Visual studio project.
I have a .Net6 C# assembly MyNet6Lib, which references my C++/CLI dll MyClrLib.dll, which is also built against ....
-2
votes
0
answers
27
views
Changing directory with _chdir does not work
I have three forms:
Login form
Database filling form
Identification form
I pass the entered login from the login form through the textBox to the other two forms in order to get to the database ...
-2
votes
1
answer
26
views
How to save XmlTextReader strings inside a variable or vector in C++/CLI?
I am currently working on a project in which I have to receive a XML file and sort one of the elements.
Before actually getting to the sorting part, I have to parse the XML file, so I am using ...
1
vote
1
answer
39
views
C# references to C++ CLR x32 and x64
I created a C++ project in Visual Studio Class library CLR (.NET Framework):
#pragma once
using namespace System;
#ifdef _M_X64
namespace MyDLL64 {
#else
namespace MyDLL32 {
#endif
public ref ...
-1
votes
1
answer
36
views
Type name not allowed (Convert)
I have two textBox, a button and a textBox where the result will be
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
double x = 0;
...
-2
votes
1
answer
24
views
.net preview 7 - c++ static virtual methods of interfaces are not supported and will be unavailable
I'm trying to use:
Visual Studio = Version 17.3.0 Preview 1.1
And Microsoft.NET SDK 7.0.100-preview.4.22252.9 (x64)
I've been able to compile some csproj projects but for my vcxproj I am getting:
6>...
-2
votes
1
answer
122
views
Winforms: Change background colour of an element depending on value of a variable
I have a small project here in visual studio 2022, a Winforms c++/CLR project.
It is a pretty simple project and form, but I have an issue with the following:
In the Winforms app I use a small panel ...
-3
votes
1
answer
61
views
C++- Duplicate data in datagridview
I try to make winform to add data to database but the dat duplicated in datagridview but in the database it's not duplicated
I try data to several tables at once is there any other ways to solve?
I ...
-2
votes
1
answer
29
views
Why do I have to convert this?(StringToNative)
This is part of a speech recognition project using the Google speech to text api. And I don't know what this code does. Do you know any friends?
ref class Converters {
public:
static size_t ...
-2
votes
0
answers
19
views
refresh datagridview in c++cli/clr windows form
After a lot of research i still don't know well how we really refresh a datagridview, i already modified things in with other command in my programme.
I just want want a button when clicked it refresh ...
-3
votes
0
answers
43
views
C++, Stack overflow error occurred in using uniform_ int_ distribution to initialize 2D array [duplicate]
#include<random>
int main() {
int a[1024][768] = {1};
int b[768][1024] = {1};
int i = 0, j = 0;
std::default_random_engine e(4);
std::uniform_int_distribution&...
-2
votes
1
answer
29
views
change format of C++/CLI stopwatch from System::Diagnostics windows form CLR
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
this->label3->Text = stopWatch.Elapsed.ToString();}
I need help for changing the format of my stopWatch, ...
-2
votes
0
answers
31
views
C++ Multithreading and Gui
I'm developing an application in Visual Studio with Cpp. Under normal conditions, we can call multithreading software from the main and we don't get any errors. But why am I getting this error here?
#...
0
votes
1
answer
26
views
VC++ How to SUM two biginteger numbers
Say I have
static System::Numerics::BigInteger MinimoNumero; int16_t Uno = 1;
static System::Numerics::BigInteger MaximoNumero;
static const std::string MaximoNumeroString = "...
-2
votes
1
answer
33
views
Microsoft Visual C++ Target O/S
I am working on a .NET application that is using C++ libraries. One library is a C++/CLR library that uses another C++ library. The application that uses these libraries is required to operate at ...
0
votes
1
answer
113
views
Convert steady_clock::time_point (C++) to System::DateTime (C++/CLI)
I need to convert C++ std::chrono::steady_clock::time_point to C++/CLI System::DateTime.
Background:
I am wrapping a C++ library with a C++/CLI interface, to be used by a .NET app.
One of the C++ ...
-1
votes
1
answer
30
views
Boost's stacktrace library doesn't work with C++ CLI
I have been using the Boost stacktrace library to print out a stacktrace of my program.
Boost 1.78.0
When compiling with pure C++ it compiles and my program prints the stacktrace nicely.
However when ...
-2
votes
1
answer
56
views
Error using C++/CLI dll in Azure function (zip deployed)
So I have:
a c++/cli wrapper withini a clr c++ dll
a c# net6 azure function which is referencing the c++/cli project
The issue:
It works perfectly when I'm testing it in local (with visual studio)
...
1
vote
1
answer
39
views
Enum::GetValues() returns zero elements
I've got problem with method Enum::GetValues(). It returns nothing - no error, no elements. Length of 'a' is zero. This code is from Microsoft website, so this is official example. I can't make it ...
-1
votes
1
answer
98
views
Calling a native C++ method from C++/CLI
I'm developing Wordle in C++ using a .net graphic interface with visual studio. I have a file.h that contains a class "WordDatabase", and I need to use one of the methods of this class in my ...
-1
votes
1
answer
39
views
How can i create an Array of textBox in c++ with a NET framework?
I'm developing Wordle in C++ and I'm using the NET graphic framework, I have created 30 textBoxes with the drag and drop interface but in order to make my program work I need to put them in a ...
-1
votes
1
answer
52
views
C++/CLI expression must be an lvalue or a function designator
For my homework I have to create an array with 10 purses and initialize 10 threads to start working individually on each purse by removing coins from one purse and add coins to another
this is what I ...
-3
votes
1
answer
57
views
Passing message in std::exception from managed code to unmanaged
I am trying to throw a std::exception from managed code so that it is caught in unmanaged code. Where I'm struggling is passing a string (describing the exception) so that the (re-)caught exception ...
1
vote
0
answers
98
views
How to correct use SAFEARRAY of Variants in C++/CLI
I have an array of variant data that I need to acquire on the native side and then marshall into the managed size. Some members of the array are themselves an array so I'm trying to populate these ...
-2
votes
1
answer
51
views
Type <String^> in list or vector in C++/CLI (CLR Console Application)
About to use a stl::list (or std::vector, previously), I got stuck with this error message:
error C3699: '&&' : cannot use this indirection on type 'System::String ^'
Since I am not very ...
-1
votes
1
answer
35
views
C++ CLI Saxon .NET gives error : java.lang.IllegalArgumentException: 'Externally supplied NodeInfo belongs to the wrong Configuration'
C++ code :
void applyXslt(Saxon::Api::XdmNode^ fxmlFile, Saxon::Api::XsltTransformer^ xsltFile, const std::string& outputFile)
{
// Apply the xslt to the cached xml
auto processor = gcnew ...
-2
votes
1
answer
58
views
Saxon .NET with C++ CLI
I had an idea to use C++ CLI to interact with the Saxon .NET interface . The problem is that every single example on Saxonica is with C# , and not C++ . can you give me an example that caches an XML ...
2
votes
0
answers
89
views
How to reliably reference WindowsBase assembly from C++/CLI
My .NET 6.0 based C++/CLI projects uses WindowsBase with the following in the project file
<Reference Include="WindowsBase">
<HintPath>$(NetCoreTargetingPackRoot)\Microsoft....
-3
votes
1
answer
43
views
How to efficiently marshal array of objects to native function using C++/CLI
I have array of objects holding primitive types and enums; how do I marshal a pointer to this data to a native function with the signature native_func(void* ptr[]).
array<System::Object^>^ ...
0
votes
1
answer
170
views
How can this warning of InteropServices.SEHException be real?
I prevent unmanaged C++ exceptions from escaping from my C++/CLI code by wrapping unmanaged calls with exception frames where I catch const std::exception&. But I've got a code-path in which the ...
-2
votes
1
answer
63
views
Trackbar functions
I'm learning C++/CLI with .NET in Visual Studio.
I want to create a TrackBar, where the minimum value is RGB white and the maximum value is RGB black.
I've dropped into the Form a Label that shows the ...
-1
votes
1
answer
44
views
Visual C++ WinForms. When using marshaling occurs: Error C2731 'WinMain': function cannot be overloaded
I am creating a GUI app in Visual C++, WinForms, Visual Studio 2022
When this library in included #include <msclr\marshal_cppstd.h>
The following error appears: Error C2731 'WinMain': function ...
0
votes
0
answers
51
views
Upgrade TargetFramework for C++ project
I have changed target framework from <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> to <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> for a C++ project.
And now ...
-2
votes
1
answer
40
views
C++/CLI Conversion of byte* to Managed Byte[]
I'm in a C++/CLI project, and I have a byte* variable that I want to fully convert into a managed array<byte> as efficiently as possible.
Currently, the only way that I've seen is to manually ...
0
votes
0
answers
113
views
vstest.console.exe: Collecting Coverage of C++/CLI project requires <CollectAspDotNet>true</CollectAspDotNet>?
TLDR: Using the Microsoft Test Platform, I only get code coverage for any C++/CLI (CLR) mixed assembly if I set the <CollectAspDotNet>true</CollectAspDotNet> in the .runsettings file. Why ...
-1
votes
1
answer
48
views
Trying to implement NTP Client using Managed C++ but getting date from 1899 using time.windows.com
I am trying to implement a code to get time from time.windows.com but it returns a weird date (year of the date I get is 1899). Since the same servers work for my unmanaged C++ code using WinSock, I ...