managed-c++

Problem in double.Parse in Managed C++

耗尽温柔 提交于 2019-12-11 05:17:39
问题 I am getting a weird problem while parsing a double value in managed C++. It may be that I am doing something wrong. When I do: double value = 0.006; result = Math::Parse( value) The output of result is 0.006000000000001 . Why it is appending a 1? Also when I go an round the value to 5 decimal places, it fails. I am doing: result2 = Math::Round(result, 5) But result2 is always 0.006000000000001 . What am I doing wrong? 回答1: It is normal. This problem caused by IEEE format of double - in real

Generic Generics in Managed C++

只谈情不闲聊 提交于 2019-12-11 00:16:43
问题 I want to create a List of KeyValuePair s in a managed C++ project. Here is the syntax I'm using List<KeyValuePair<String^, String^>^>^ thing; but I'm getting the following error: error C3225: generic type argument for 'T' cannot be 'System::Collections::Generic::KeyValuePair ^', it must be a value type or a handle to a reference type I basically want to do this (C#) List<KeyValuePair<string, string>> thing; but in managed C++. Oh and in .Net 2.0. Any takers? 回答1: KeyValuePair does not itself

I get LNK2028 when trying to wrap native c++ class using managed c++

走远了吗. 提交于 2019-12-10 13:45:32
问题 trying to wrap a native cpp class using managed c++ class. all looks good but for some reason it wont compile. getting the following linker errors: Error 25 error LNK2028: unresolved token (0A0002CE) Error 27 error LNK2019: unresolved external symbol Any ideas how do I fix this one ? :\ well, here is a full error of one of the functions: Error 20 error LNK2028: unresolved token (0A0002CF) "public: bool __thiscall RCSclient::ResumeChannel(char *,int,__int64)" (?ResumeChannel@RCSclient@@$$FQAE

C++/CLI : Why can't I pass Strings by reference?

蹲街弑〆低调 提交于 2019-12-10 13:24:36
问题 Why doesn't Microsoft's C++/CLI allow me to pass strings by reference? I received the following error: C3699: '&': cannot use this indirection on type 'System::String' 回答1: Sounds like you are using Managed C++, which is a bastardised C++ used with the .NET Framework. in Managed C++, I believe the syntax you are looking for is System::String^ . The reason for this is that since managed types are garbage collected by .NET Framework, you aren't allowed to create 'regular' references since the

Convert from int to int32

孤人 提交于 2019-12-10 09:27:24
问题 I have a bunch of int's in my c++ code that I need to change to int32's. Same with my bool's. What header do I need to include in order to use int32's and bool32's. Also how do I declare these once I make them. Am I able to just replace the int's with int32's? For example: int x; Becomes int32 x; I am getting lots of errors when I try to change from int to int32. Here's a few: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C2086: 'const int x'

Loading mixed mode assembly from unmanaged code

爷,独闯天下 提交于 2019-12-07 17:07:43
问题 As the title says i want to call a mixed mode assembly from unmanaged code. To be more precise, i want to load the mixed mode assembly dynamically and then execute some static unmanaged startup code that registers some Managed C++ Wrappers for C# Code. Is this possible (or do i need to embed the .Net Runtime or use COM?) ? Has anybody already done this and can share some experience? PS: If the mixed mode assembly contains a WPF Window will it be started? 回答1: You need to get the CLR loaded

Arrays of strings in Managed C++

十年热恋 提交于 2019-12-06 23:15:41
问题 I'm trying to write an application in Managed C++, but I cannot work out how to declare an array of strings. String^ linet[]; throws an error 'System::String ^' : a native array cannot contain this managed type So I suppose there's a different way to do this for managed data types. What exactly is it? 回答1: Do you really mean Managed C++? Not C++/CLI? Assuming you're actually using C++/CLI (because of the error message you posted), there are two ways to do this: array<String^>^ managedArray =

Managed C++ and AnyCPU

白昼怎懂夜的黑 提交于 2019-12-06 22:27:35
问题 I have a Managed C++ dll that I am referencing from a C# project. The C# project will be compiled as AnyCPU. Is there any way to compile a 32-bit and 64-bit version of the Managed C++ dll and then tell the C# project at runtime to load the correct one depending on which architecture it is being run? 回答1: The trick to getting the AnyCPU dll to play with the C++ dll, is at runtime make sure the assembly cannot load the C++ dll and then subscribe to the AppDomain AssemblyResolve event. When the

Loading mixed mode assembly from unmanaged code

扶醉桌前 提交于 2019-12-05 18:36:09
As the title says i want to call a mixed mode assembly from unmanaged code. To be more precise, i want to load the mixed mode assembly dynamically and then execute some static unmanaged startup code that registers some Managed C++ Wrappers for C# Code. Is this possible (or do i need to embed the .Net Runtime or use COM?) ? Has anybody already done this and can share some experience? PS: If the mixed mode assembly contains a WPF Window will it be started? You need to get the CLR loaded and initialized. Yes, making a managed class [ComVisible] or hosting the CLR yourself with CorBindToRuntimeEx(

_CRT_DEBUGGER_HOOK throws exception

可紊 提交于 2019-12-05 10:14:23
I'm having a problem converting my program from VS2005 to VS2008. When I run the program in VS2008, the application starts up fine but when start playing around with the application it crashes giving me this error: "Microsoft Visual Studio C Runtime Library has detected a fatal error" And then the debugger points me to this function: __declspec(noinline) void __cdecl _CRT_DEBUGGER_HOOK(int _Reserved) { /* assign 0 to _debugger_hook_dummy so that the function is not folded in retail */ (_Reserved); _debugger_hook_dummy = 0; } compiling the application ase release works prefectly... By the way,