This is my first attempt to call a .NET assembly from a Delphi 5 (Win32) native assembly. I am only familiar with C# and .NET so please bear with me.
I guess I will walk thru this layer by layer. Here is the code for the C# assembly I am attempting to execute from the Delphi 5 assembly.
using System;
using System.Collections.Generic;
us...
I've got a generic range class and I'm trying to add a comparison operator so I can test whether one range is equal to another. It fails to compile and I'm not sure how to fix the issues it's complaining about. Have I missed something obvious? Here's a snippet of the code:
generic<typename T>
public ref class Range
{
protected:
T m_...
I noticed that there are sealed and interface keywords in C++. Is this just for CLR C++?
If not, when were sealed and interface added to the C++ standard? Do they have the same meaning in C++ as they do in C#? If not, how do I get the equivalent in standard C++?
...
How I can translate small C++/CLI project to c#
...
When I try to create a class in managed C++ that inherits from ObservableCollection I get the error:
error C2039: 'ObservableCollection' : is not a member of 'System::Collections::ObjectModel'
Here's my code:
using namespace System;
using namespace System::Collections;
using namespace System::Collections::Generic;
using namespace Sys...
I have the following code, which I thought would work:
property Nullable<double> Angle {
Nullable<double> get() {
return nullptr;
}
}
It doesn't. How can I do it? Does c++/CLI even support nullable types?
...
I am trying to do
property double Real;
and then
double Data::ComplexNumber::Real::get() {
return _real;
}
But it is giving error. How do you go about declaring the methods in the header file and then actually implementing them? Do you use this approach in c++/cli, or you'll go the c#/vb.net way of declaring the classes and imp...
Has anyone ever tried creating a class which implements the DebuggerTypeProxy attribute?
I have done it successfully in c#, but even when creating simple classes in c++/cli, it doesn't seem to work. I am aware c++'s IDE doesn't recognize it, but I am compiling everything in c++/cli and then running it on c#.
#pragma once
using namespac...
I want to port the following code from c# to c++/cli:
class MyClass : IEnumerable<int> { ... }
I've tried
class ref class MyClass : IEnumerable<int>
but it doesn't seem to be working.
...
I'm trying to convert this c# code into c++/cli code:
class MyRange : IEnumerable<int>
{
public IEnumerator<int> GetEnumerator() { return null; }
IEnumerator IEnumerable.GetEnumerator() { return null; }
}
Here is my attempt:
namespace Tests {
public ref class MyRange : System::Collections::Generic::IEnumerable<int> {
...
Here is my code:
using namespace System;
using namespace System::Collections;
using namespace System::Collections::Generic;
namespace Tests {
ref class MyCollection : public IEnumerable<int> <----HERE!
The C# compiler, for instance, will recognize that the only IEnumerable<T> it has in those namespaces is from System::Collections...
How does it work? Does it have distinct parts - some methods are managed, some are unmanaged, does it convert every method to managed, trying to keep everything managed and doing the interop calls when he must?
...
I'm trying to translate this c++/cli code to c#
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
using namespace System;
using namespace System::Runtime::InteropServices;
struct CREDENTIAL
{
DWORD Flags;
DWORD Type;
LPSTR TargetName;
LPSTR Comment;
...
I have a native C++ DLL that uses COM ADO Recordsets and am in need of converting it to the .NET variant (ADODB::Recordset). I have tried several approaches to tackling this problem without success.
The native C++ DLL dynamically creates and populates the COM Recordset. Ideally I'd do the same for the ADODB::Recordset within the manage...
I'm using C++/CLI on Windows. It's an MFC app built with /clr.
I want to test how long it takes my application to start up. The first time it took 10s, but subsequently it took 4s, 4s, 5s. I'm assuming this is due to Windows caching the DLLs.
Is there some tool that will allow me to remove a directory from the cache, so that my test co...
Hello all,
I want to delete a 2 level derived class with a function and putting its handle to null.
A piece of code will be helpfull:
ref class bob
{
};
ref class bill : public bob
{
};
ref class jack : public bill
{
};
void DeleteX( bob ^% x )
{
if( x != nullptr )
{
delete x;
x = nullptr;
}
}
[STAThreadAttribute]
int...
I have a project written in C++/CLI. Some of the types there are in managed code, and some are in completely native code. Let's say I have the produced DLL on a machine that dosen't have any version of the .Net framework installed, is there a way that another, native application will link with my "mixed-mode" Dll and use only the native ...
I am trying to create a generic list of references to PointF objects. (No, I am not looking to create a generic list of PointF objects.) However, the following line fails to compile:
Generic::List<PointF^> ^pointList; // Generates error C3225
On the other hand, creating an array of PointF references works without a problem as follows:...
I have a C++/CLI GUI application and I want to display an image as a visual aid for the user to see what step in a procedure they're at. This image will need to be changed each time the user selects the new step.
Currently I'm using a picture box and have an image loaded from the disk at run time. So there are a few things I need to kno...
I've been trying to swap images in a PictureBox in a C++/CLI application but my solution appears to have a memory leak:
System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
// Pick a new bitmap
static int resource = IDB_BITMAP1;
if( resource == IDB_BITMAP2)
{
resource = IDB_BITMAP1;
}
else
{
resource =...