c++-cli

A Program that sits in the Notification Area

Hello, Thanks for taking the time to read my question. If I build a program, how can I get it to hide in the notifications area(windows 7, cant remember what it's called in XP or Vista) when I minimize it? Like say a Torrent program, or a AntiVirus program. Also I'd like to know, how can I hide it from the notifications area and brin...

Partial coverage of a return statement in C++/CLI

I have C++/CLI code and I'm using Visual Studio 2008 Team Suite Code Coverage. The code header: // Library.h #pragma once #include <string> using namespace System; namespace Library { public ref class MyClass { public: static void MyFoo(); static std::string Foo(); }; } The code implementation: #include "Libr...

PInvoke or using /clr:pure to compile

I have a set of numerical libraries in C++ and I want to call them interactively in a interpretive language like F# or IronPython. So I have two choices now: Compile the library in native DLL and use PInvoke to call functions in it. Compile the C++ library to .Net dll using visual c++ (/clr:pure compile option). The advantage of 1...

C++/CLI: Compiling static library with /CLR support

We have old (working) code that consists of a static library compiled with /CLR, and a C++/CLI DLL that links to the static lib. We are about to add new features to this static lib. Now, I've have heard from numerous sources that CLR static libraries are not supported by Microsoft, and therefore I'm pushing to clean this up and switch t...

C++/CLI, "constant" reference to a tracking handle

Hello, I have spotted something like this in code: void foo(IList<int>^ const & list ) { ... } What does this ^ const& mean? I looked in the C++/CLI specification, but found no comments on making constant tracking references, nor the ^& combo. Is this legal? ...

ObjectDisposedException from core .NET code

I'm having this issue with a live app. (Unfortunately this is post-mortem debugging - I only have this stack trace. I've never seen this personally, nor am I able to reproduce). I get this Exception: message=Cannot access a disposed object. Object name: 'Button'. exceptionMessage=Cannot access a disposed object. Object name: 'Button'....

C2360 compiler error on TFS build, but not on desktop

A c++/cli code snippet similar to the code below caused our TFS build to fail with a C2360 compiler error. switch (i) { case 0 : for each (int n in a) System::Console::WriteLine(n.ToString()); break; case 1 : System::Console::WriteLine("n is not in scope here"); break; } This is fixed by...

ftp .net getdirectory size

hi i write method which must to know that is size of specified directory i get response from server which contains flags of file name size and other info and on the different ftp servers format of answer is different how to know format of answer? unsigned long long GetFtpDirSize(String^ ftpDir) { unsigned long long size = 0; int j = 0...

Screen Resolution Question VS2008 - C++ CLI

Hi, I have a program that has a SIZE of 800x600. I want to make this program expand if it is maximized, so that all the elements(buttons, picturebox's) change size to fit the new ratio depending on the users windows screen resolution. The way I am thinking to approach this is to take the users screen resolution and manual change the s...

C++/CLI value class constraint won't compile. Why?

Hello, a few weeks ago a co-worker of mine spent about two hours finding out why this piece of C++/CLI code won't compile with Visual Studio 2008 (I just tested it with Visual Studio 2010... same story). public ref class Test { generic<class T> where T : value class void MyMethod(Nullable<T> nullable) { } }; The ...

Copying a 14bit grayscale image (saved in long[]) to a pictureBox

My camera gives me 14bit grayscale images, but the API's function returns a long* to the image data. (so i'm assuming 4 bytes for each pixel) My application is written in C++/CLI, and the pictureBox is of .NET type. I am currently using the BitmapData.LockBits() mechanism to gain pointer access to the image data, and using memcpy(bmpDat...

How do I call C++/CLI (.NET) DLLs from standard, unmanaged non-.NET applications?

In the unmanaged world, I was able to write a __declspec(dllexport) or, alternatively, use a .DEF file to expose a function to be able to call a DLL. (Because of name mangling in C++ for the __stdcall, I put aliases into the .DEF file so certain applications could re-use certain exported DLL functions.) Now, I am interested in being ab...

C++ : how to access an object created in Form1?

hi.. i am new in C++, i'm using VC++ 2008, i have created a form with pictureBox inside with gui design, located in Form1.h. for code stability, i'm trying to separate beetween gui and processing classes, so i made a new class in process.h which contain code to change image in the pictureBox, the problem is that i cant access pictureBo...

Why do I get CA1806 when I catch exception in C++/CLI?

I've recently upgraded my project from Visual Studio 2008 to Visual Studio 2010. By enabling Code Analysis and compiling in Release, I'm getting warning CA1806: Do not ignore method results. I've managed to reduce the code that produces the warning to this code: .h file: public ref class Foo { public: void Bar(); }; .cpp file: ...

Why do I get CA1811 when I call a private method from a public method in C++/CLI?

I've recently upgraded my project from Visual Studio 2008 to Visual Studio 2010. By enabling Code Analysis and building on Release, I'm getting warning CA1811: Avoid uncalled private code. I've managed to reduce the code to this: .h file: public ref class Foo { public: virtual System::String^ ToString() override; private: st...

Can I use both C# and C++/CLI in a single assembly?

Can I put together both C# and C++/CLI source files in a single project, and then compile them to obtain a single .DLL assembly? ...

Why don't I get code coverage results for C++/CLI project in Visual Studio 2010?

I've recently upgrade my solution to Visual Studio 2010. I have 4 projects I want to cover using unit tests - 3 C# and 1 C++/CLI. I get coverage for the C# projects but not for the C++/CLI project. I did get for all of them in Visual Studio 2008. I've configured the assemblies using testrunconfig -> Data and Diagnostics -> Code Cover...

Multilevel inheritance problem

Hi, Please help me on this puzzle i have class D inherited fronm class B and class C, these class C and Class D again inherited from class A. In class D i have to access function in class A. is it possible ...

How can I set the Root Namespace property correctly in a C++/CLI application?

I have a C++/CLI application in Visual Studio 2008 whose namespace follows the .NET guideline of CompanyName.TechnologyName[.Feature][.Design]. The problem is that there seems to be no way to set a multi-level namespace in the project's Root Namespace property. I have tried both CompanyName.TechnologyName and CompanyName::TechnologyNam...

Do you recommend Enabling Code Analysis for C/C++ on Build?

I'm using Visual Studio 2010, and in my C++/CLI project there are two Code Analysis settings: Enable Code Analysis on Build Enable Code Analysis for C/C++ on Build My question is about the second setting. I've enabled it and it takes a long time to run and it doesn't find much. Do you recommend enabling this feature? Why? ...