managed-c++

Windows Forms Timer bug or bad use?

When programming a small OpenGL application using Windows Forms, I discovered something using a profiler that I thought was pretty wonky. I'm using a System::Windows::Forms::Timer to detect a combination of mouse idling and some other user input. The tick functionality is useful, but on occasion I want to 'reset' the timer. You can't r...

Dynamic Memory Allocation in C++

What is the difference between the 'delete' and 'dispose' C++ operators with regards to dynamic memory allocation? ...

Managed C++ internal class?

Is there a may to make a managed C++ class "internal"? I.E. What is the equivalent of "internal class" in managed C++? ...

Exposing unmanaged const static std::string in a managed C++ class

I have a non-.NET C++ class as follows: Foo.h: namespace foo { const static std::string FOO; ... } Foo.cc: using namespace foo; const std::string FOO = "foo"; I want to expose this for use in a C# application, but I keep getting errors about mixed types when I try the following: FooManaged.h: namespace foo { namespace NET...

Creating 64 bit CLR C++ projects in VS2008

I am creating a wrapper around a native lib, which comes in both 32 & 64 bit flavors. I have a fairly complex C++/CLR project that includes a number of header files from the native libs. I got it to work fine on x32, but now I'm not sure how to provide an alternative x64 build. Can someone outline the steps to create such project? Var...

Passing a managed reference to a method taking unmanaged pointer

Is it possible to make this work? template<class T> fun(T * t) { t->someMemberFunc(); } ... somewhere in the code: ManagedType ^ managedP = gcnew ManagedType(); UnmanagedType * unmanagedP = new UnmanagedType(); fun(managedP); ...

Managed C++ ^ (handle) --> What is it and how does it relate to references and pointers

What is the difference between a handle to an object in Managed C++ such as: System::String^ str = gcnew System::String(); and the ordinary C++ pointers? Also how do they relate to references we have in C#? ...

Managed C++: Strings in List is not passed back to caller

I have a C# .Net console application which calls a C++ .Net class library. However, when the following application is executed, the list becomes empty!!! If I remove the line as indicated in the comment next to it, the code works. I don't understand the reason for this. If I want to reallocate the memory for list in the C++ class libr...

The speed of .NET in numerical computing

In my experience, .net is 2 to 3 times slower than native code. (I implemented L-BFGS for multivariate optimization). I have traced the ads on stackoverflow to http://www.centerspace.net/products/ the speed is really amazing, the speed is close to native code. How can they do that? They said that: Q. Is NMath "pure" .NET? A. The ans...

My application is unmanaged. Where do I start introducing managed code?

My whole application (which is rather big, with a 20MB executable) is written in unmanaged C++. Because I can clearly see the advantages in using managed code, I want to start introducing managed code in my application, but where do I start? Can I easily start to use C++/CLI and link it with the rest of my application? (although the C++...

Gdiplus in C++ managed or unmanaged?

is this file with namespace Gdiplus in c++ managed or unmanaged code? ...

gcnew KeyEventHandler compile problem (VC++)

My managed c++ code fails to compile with the error message .\Window.cpp(11) : error C2440: 'initializing' : cannot convert from 'System::Windows::Forms::Form ^' to 'Enviroment::Window ^' No user-defined-conversion operator available, or Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast o...

Passing a Delegate as Callback to a Native C++ API Call

Could someone point me whats wrong with this code please? I'm having a very hard experience in mixing C++ and MC++. I have read a lot of blogs and tutorial regarding this subject (passing delegates) but now that looks my code is ok (its compiling and runs well when in debug mode and step by step) it crashs. The main problem is that it n...

Cast native pointer to a C++\CLI manged object reference?

hi, I have a callback that is called through a delegate. Inside it I will need to treat the buffer data that arrive from a record procedure. Normaly in a unmanaged context I could do a reinterpret_cast on dwParam1 to get the object reference. But in a manged context how can I cast a DWORD_PTR to a managed object ref? static void Wav...

Compiler can't find structures, what should i be including.

UPDATE: I thought it was Windsows.h i need to include and you have confirmed this, but when i do include it i get a bunch of messages like the following... 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(5934) : error C2872: 'IDataObject' : ambiguous symbol 1> could be 'C:\Program Files\Microsoft SDKs\Windows\v6....

ambiguous symbols

1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(5934) : error C2872: 'IDataObject' : ambiguous symbol 1> could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(251) : System::Windows::Forms::IDataObject IDataObject' 1> or 'c:\windows\microsoft.net\framework\v2.0.50727\system.windows....

How to do exception handling in mixed applications? (managed application using unmanaged DLL)

Is it possible to throw exceptions in an unmanaged DLL and handle it in a managed application? My unmanaged C++ DLL throws exceptions in case of errors, and they should be handled in the calling executable application. CMyFileException *x = new CMyFileException; throw(x); This previously worked, but now the application is compiled w...

Possible to embed a C++ dx renderer in a C# app without using managed c++?

I have a renderer written in C++ and directX. I now want to write a (level / scene / UI) editor and if possible / realistic I would prefer to write the interface to my editor in C#/.net Is this at all feasible, without going down a route of managed c++? Can I expose the necessary interface from my renderer to a C# app, without managed...

What's the difference between managed C++ and C#?

The major advantage I see for using C++ instead of C# is compiling to native code, so we get better performance. C# is easier, but compiles to managed code. Why would anyone use managed C++ for? What advantages it gives us? ...

How do I call native C++ from C#?

I have a class implemented in C++ that's responsible for the arithmetic computation of the program, and an interface using WPF. I process the input with C# but then how can I use my C++ class? I've seen some comments about making a managed C++ wrapper class to interact with it, but I don't know where to start. Nor do I know how I'd go t...