I have a CLI/C++ interface that I want to examine via .NET Reflection. Here's the function signature in the source code:
class ClassA;
template<typename _Type> class ClassTempA;
public interface class Test : BaseFunc {
public:
ClassTempA<int>& SomeFunc2(ClassA inst) = 0;
};
Here's what the function looks like when examined in .N...
InternalsVisibleTo is not working for my managed C++ projects, but it is for my C# projects. Any help would be appreciated. Here is a simplified layout.
Project A - C#, has an internal property I want to access from B/C.
Project B - Managed C++. References A.
Project C - C#, references A.
All projects are signed with the same key. Lo...
Any idea how to initialize .NET delegate that points to method from 'mixed' class instance?
I have 'mixed' C++ class like this:
class CppMixClass
{
public:
CppMixClass(void){
dotNETclass->StateChanged += gcnew DotNetClass::ServiceStateEventHandler(&UpdateHealthState);
}
~CppMixClass(void);
void UpdateState(System:...
Hi,
I was wondering what's the proper way of raising events from C++/CLI. In C# one should first make a copy of the handler, check if it's not null, and then call it. Is there a similar practice for C++/CLI?
...
I know I'm not asking this quite right, either. Please help me better form my question.
I'm having a bit of a hard time getting my mind wrapped around handles -- in some ways, it looks like pointers. But unlike pointers, it seems like I can assign values directly to the handle variable, and it affects the underlying data value, not t...
I am working on a drawing-based product where I want to produce versions for iPhone, desktop OS/X, Windows Tablets, Silveright-based browser, Windows Mobile, and Windows in that order of priority.
For GUI portability, the classic answer is to keep the core in C++ and use Cocoa/Objective-C or WPF/C# thin layers.
However, Silverlight com...
I'm writing a command line interpreter and I'm trying to setup formats for individual commands. I have things like the name of the command, the maximum amount of parameters and the minimum amount of parameters. I want to have sort of collection, a sort of prototype of what kind of types the parameters are. My first thought was just to d...
I'm updating some old Managed C++ code with lines like this:
instanceOfEventSource->add_OnMyEvent(
new EventSource::MyEventHandlerDelegate(this, MyEventHandlerMethod) );
where
EventSource is the class that publishes events
instanceOfEventSource is an instance of that class
EventSource::MyEventHandlerDelegate is the delegate typ...
In managed C++/CLI, I could do this either as (1):
array<System::Byte>^ css_keycode = {0x51, 0x67, 0x67, 0xc5, 0xe0, 0x00};
or (2):
array<System::Byte>^ css_keycode;
css_keycode = gcnew array<System::Byte>(6) {0x51, 0x67, 0x67, 0xc5, 0xe0, 0x00};
But I apparently can't do (3):
array<System::Byte>^ css_keycode;
css_keycode = {0x5...
I've got a C++ gui project exhibiting some strange behavior. On my machine, the code compiles and runs just fine. However, on another machine, The code compiles but ends up running in MTA somehow. Obviously, being in MTA causes all sorts of runtime problems for the GUI. Here is my main:
[STAThreadAttribute]
int main(...
I have an unmanged C++ class I have written in an unmanged dll. I have a managed dll that references the unmanaged dll. Can a class in the managed dll derive from the unmanaged class?
Using Visual Studio 2008
...
Hi,
I have a C++ library app which talks to a C++ server and I am creating a vector of my custom class objects. But my Cpp/CLI console app(which interacts with native C++ ), throws a memory violation error when I try to return my custom class obj vector.
Code Sample -
In my native C++ class -
std::vector<a> GetStuff(int x)
{
-- do...
So I'm trying to call a function that is a manged wrapper around an OCX object. Having great difficulty. Function is;
foo(System::Object ^% theBuffer)
where 'theBuffer' is an array of bytes. The template for the unmanaged OCX which 'foo' wraps is
goo(VARIANT* theBuffer);
So I've tried;
System::Int32 buf[10];
foo(buf);
which fail...
I have Visual Studio 2008 (9.0.30729.1 SP) installed on my computer and a build machine. On my computer, a project builds fine. On the build machine, I have started getting this error.
ALINK operation failed (80070005) : Access is denied
This is incredibly irritating because it doesn't say Access TO WHAT??? is denied.
I've tried rebo...
i have an enum declared as
enum class AccessLevel : int
{
ReadOnly = 0,
Excluded = 1,
ReadWrite = 2,
};
and an Array declared as
static array<String^>^ _accessMap = gcnew array<String^> { "R", "X", "W" };
I want to do something like this:
AccessLevel^ access = access::ReadOnly;
String^ foo = _accessMap[access];
...
C++/CLI helpfully generates the IDisposable scaffolding for you when you implement a destructor on a ref class. Also, if you don't implement a destructor, but your class has a member variable which implements IDisposable, then IDisposable is again automatically implemented on your class. It's pretty helpful and much better than how IDisp...
I have some C++/CLI code that needs to pin a struct (value type) in order to pass it back to unmanaged code. The unmanaged code knows enough to unmarshal what it needs.
The struct may contain managed strings and so I also need to pin these before calling the unmanaged function.
The problem is that my managed helper class is generic:
...
I have Visual Studio 2008 SP1, two C++/CLI projects, lets say proj1 and proj2.
proj2 is dependent on proj1, but in a weird way (see below).
In Project Dependencies I specify that proj2 depends on proj1.
Also proj2 references include proj1.
Then I want proj1 to be a friend to proj2,
so, as MSDN page on "Friend Assemblies" says, I write so...
I have a small namespace containing some type definitions, which I use to make my code look cleaner. However I don't want to have to add a "using namespace ..." line to every file that uses one of these types, after all I already have to add a #include for the file.
MyFile.cpp:
#include "typedefs.h"
void Bob()
{
IntList^ list = gcne...
Hi,
I'm writing my custom events in C++/CLI (I pretty much only care about the add/remove methods) as such:
event EventHandler<XyzEventArgs^> ^Xyz
{
void add(EventHandler<XyzEventArgs^> ^handler);
void remove(EventHandler<XyzEventArgs^> ^handler);
void raise(Object ^sender, XyzEventArgs ^e);
}
Ever...