c++-cli

What does "Value does not fall within expected range" mean in runtime error?

Hi, I'm writing a plugin (dll file) using /clr and trying to implement speech recognition using .NET. But when I run it, I got a runtime error saying "Value does not fall within expected range", what does the message mean? public ref class Dialog : public System::Windows::Forms::Form { public: SpeechRecognitionEngine^ sre...

Lambdas in C++/CLI

How to use lamda expressions in C++/CLI? ...

Reading from an embedded resource stream

I've been trying to access an image resource named "IndexPointer.jpg" in an embedded RESX file called "Images.resx". GetManifestResourceNames() returns a single value - SCtor.Images.resources". Assembly::GetExecutingAssembly()->GetManifestResourceStream("SCtor.Images.resources.IndexPointer.jpg") only returns a nullptr. Obviously, I've...

C# SendMessage to C++ WinProc

I need to send a string from C# to a C++ WindowProc. There are a number of related questions on SO related to this, but none of the answers have worked for me. Here's the situation: PInvoke: [DllImport("user32", CharSet = CharSet.Auto)] public extern static int SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, string lParam); C#: stri...

Is there an easy way to sign a C++ CLI assembly in VS 2010?

Right now I am setting the Linker/Advanced/KeyFile option. I am getting the "mt.exe : general warning 810100b3: is a strong-name signed assembly and embedding a manifest invalidates the signature. You will need to re-sign this file to make it a valid assembly.". Reading from the web, it sounds like I have to set the delay signing opti...

How to define a macro that retains its scope after it's been called

I'm trying to make a macro to make it easier to define properties. Simplified example but at the moment I have this to provide a property with a public get and private set: #define propertyRO(xxType, xxName)\ property xxType xxName\ {\ xxType get() {return m___##xxName;}\ void set(xxType value) {m___##xxName = v...

File using .net sockets, transferring problem

I have a client and server, client sending file to server. When i transfer files on my computer(in local) everything is ok(try to sen file over 700mb). When i try to sent file use Internet to my friend in the end of sending appears error on server "Input string is not in correct format".This error appears in this expression fSize = Con...

C++/CLI: CA2123: Requires SecurityCriticalAttribute?

I am a little lost on erros like that: Warning 7 CA2123 : Microsoft.Security : Add the following security attribute to 'RithmicConnector::Connect(String^)' in order to match a LinkDemand on base method 'IConnector::Connect(String^)': 'SecurityCriticalAttribute'. c:\work\nettecture\tradex\source\tradex.connectivity.ri...

RichTextBox doesn't update caret position correctly

I have a handler consuming the keyDown event of a WinForms RTB, that has the following code: GetTextAtLoc(RTB->SelectionStart); // selects some text at the caret's position RTB->SelectedText = "SomeOfMyOwn"; GetTextAtLoc(RTB->SelectionStart); // selects the replacement string RTB->SelectionStart += RTB->SelectionLength - 1; While this...

this == null // How can it be possible?

Recently I came across some strange behaviour of my application. It has been developed mainly in C# but CLI/C++ was also used to achieve better performance. I was getting a System.NullReferenceException in a very simple method at the TimeSpan comparison: TimeSpan _timestamp; void UpdateFrame(TimeSpan timestamp) { if(TimeSpan::Equals...

No IntelliSense for c++/cli in visual studio 2010?

I just moved from Visual Studio 2008 to 2010, and noticed one major flaw: When I try to use AutoComplete in a C++ Source file for managed c++, a small note in the footer appers: intellisense for c++/cli not available Uh, has IntelliSense for c++/cli been dropped from Visual Studio 2010? Is there any way to get this back? It is rather ...

How to install MUI files into GAC?

I am writing a C++/CLI assembly that uses some native DLLs. During compile I can list them as "assembly link resource" so that the assembly is aware of these dependencies. When I use gacutils, it properly pulls all the native DLLs into GAC and they get properly loaded from GAC. Now, some of these native DLLs are localized, and have MUI ...

What's the simplest way to extract the last section of an IP address?

I have an IP address which I want to grab the last chunk of as an integer. So from "192.168.1.150" I'd get 150. This is the code I'd concocted (I'm using C++/CLI), but somehow it feels rather clunky: String^ ipString = "192.168.1.150"; int lastDot = ipString->LastIndexOf('.'); int lastSection = int::Parse(ipString->Substring(lastDot, i...

% style macros not supported in some C++/CLI project property pages under VS2010?

We're currently evaluating VS2010 and have upgraded our VS2008 C++/CLI project to the new .vcxproj format. I've noticed that a certain property we had set in the project settings did not get translated properly. Under Configuration Properties -> Managed Resources -> Resource Logical Name, we used to have (in VS2008) the setting: $(Int...

C++/CLI Mixed Mode DLL Creation

I've got a native C++ DLL that I would like to have a C++/CLI wrapper layer for. From what I understood, if you simple added a C++/CLI class to the project, VS would compile as mixed mode, but I was apparently wrong as VS doesn't seem to be even touching the managed code. So, given a pre-existing native code-base what exactly, step-by-...

extern "C" char** environ - Windows - C++/CLI

I have some old linux code I'm trying to port to Windows. When I first built it as a straight native DLL, I go no issues with this piece of code, but when I tried making it a mixed-mode C++/CLI DLL, I got an unresolved external object error on this: extern "C" char** environ; Why would this work for native and not CLI? Any idea how t...

When declaring a function in C++/CLI, what is the meaning of the signs ^ and * before and after a variable?

For example: Let's say we have a class called MyClass. String^ MyClass::GetSomeInfoForExamplePuprs( int InfoNumber ) { } or static String ^GetOtherInfoExample() { } or String ^GetOtherInfoExample(object *Something) { } I saw it in source code and can't figure it out. ...

How to create an array of buttons in C++

Hi, I'm using C++ in VS2005 and have an 8x8 grid of buttons on a form. I want to have these buttons in an array, so when I click on any of them it will open the same event handler (I think that is what they are called), but I will know the index of which one was clicked on. I know how to do this in VB and C#, but I can't seem to figure i...

Call glutinit in a PHP extension

Hi guys, I am developing a php extension that require the use of opengl. I tried to initialize the library with glutinit; it works in CLI environment but when I tried on browser it doesn't seem to execute the code. The code is actually executed on the server side. It is part of a process to extract features from an image, and the serv...

Producing Mini Dumps for _caught_ SEH exceptions in mixed code DLL

I'm trying to use code similar to clrdump to create mini dumps in my managed process. This managed process invokes C++/CLI code which invokes some native C++ static lib code, wherein SEH exceptions may be thrown (e.g. the occasional access violation). C# WinForms -> C++/CLI DLL -> Static C++ Lib -> ACC...