c++-cli

Visual C++ 2010: Changes to MSVC runtime deployment (no more SxS with manifest)

我是研究僧i 提交于 2019-11-28 17:21:10
问题 Where can I find some official note, kb article or other documentation describing changes to the Visual Studio 2010 C/C++ runtime linking and deployment policy? Under Visual Studio 2008 (with the VC90 runtime) a manifest was embedded in native images, and the runtime libraries were deployed as side-by-side assemblies (WinSxS). This caused problems when rebuilding a native exe or library using VS 2008 SP1, in that an updated version of the C++ runtime was required by the embedded manifest. For

How can I make my managed NuGet package support C++/CLI projects?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 16:56:40
I have made a NuGet package that works well when I use it from a C# project. It contains a DLL in the lib/net40 directory, and the DLL gets added as a reference. Now that NuGet supports C++, how do I actually modify my package so that the DLL can be added as a managed reference in a C++/CLI project? I can't find any tutorials explaining this. If I try to just add the package as is, I get the following error: You are trying to install this package into a project that targets 'Native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with

convert standard C++ string to String^

南笙酒味 提交于 2019-11-28 14:26:00
I want to convert to std::string to System::String^ in Visual C++ environment. I know that we can convert System::String to std::string by the MarshalString Function as below: void MarshalString ( String ^ s, string& os ) { using namespace Runtime::InteropServices; const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer(); os = chars; Marshal::FreeHGlobal(IntPtr((void*)chars)); } I can't find the way to convert std::string to System::String but I found that System::String has constructor with argument as below : System::String(Char* value, Int32 startIndex, Int32 length)

Optional parameters in managed C++/CLI methods

江枫思渺然 提交于 2019-11-28 13:15:50
How can I declare a managed method in C++/CLI that has an optional parameter when used from C#? I've decorated the parameter with both an Optional and a DefaultParameterValue attribute (see: How default parameter values are encoded ), but only the Optional attribute seems to be honored. C++/CLI: public ref class MyClass1 { public: MyClass1([System::Runtime::InteropServices::Optional] [System::Runtime::InteropServices::DefaultParameterValue(2)] int myParam1) ↑ { System::Console::WriteLine(myParam1); } }; C#: var myInstance1 = new MyClass1(); // compiles and runs Output : 0 Expected Output: 2

Lambda expressions as CLR (.NET) delegates / event handlers in Visual C++ 2010

女生的网名这么多〃 提交于 2019-11-28 12:03:30
Is it possible to use the new lambda expressions in Visual C++ 2010 as CLR event handlers? I've tried the following code: SomeEvent += gcnew EventHandler( [] (Object^ sender, EventArgs^ e) { // code here } ); It results in the following error message: error C3364: 'System::EventHandler' : invalid argument for delegate constructor; delegate target needs to be a pointer to a member function Am I attempting the impossible, or is simply my syntax wrong? No can do, the C++/CLI compiler didn't get updated to accept the lambda syntax. Fairly ironic btw given the head-start that managed code had. The

Call C# dll function from C++/CLI

こ雲淡風輕ζ 提交于 2019-11-28 12:02:00
I have a C# dll. The code is below: public class Calculate { public static int GetResult(int arg1, int arg2) { return arg1 + arg2; } public static string GetResult(string arg1, string arg2) { return arg1 + " " + arg2; } public static float GetResult(float arg1, float arg2) { return arg1 + arg2; } public Calculate() { } } Now, I am planning to call this dll from C++ on this way. [DllImport("CalculationC.dll",EntryPoint="Calculate", CallingConvention=CallingConvention::ThisCall)] extern void Calculate(); [DllImport("CalculationC.dll",EntryPoint="GetResult", CallingConvention=CallingConvention:

Could not load file or assembly The system cannot find the file specified

删除回忆录丶 提交于 2019-11-28 11:59:18
I am building a dll, which references a second dll. I have added the second dll as a reference in the first dll's project by going to Properties > Common Properties > Framework and References > Add New Reference > Browse I compiled the second dll from a third party's source code. Both projects are C++/CLI. Whenever my main application tries to call a function in the first dll which contains a call to the second dll, I get the following error: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Additional information: Could not load file or assembly

Windows Azure not finding DLL of C++/CLI project

筅森魡賤 提交于 2019-11-28 11:45:11
I have a C++/CLI project that wraps around an unmanaged C compression library, and this project is referenced by an MVC3 project that calls the C++ Compress function. Everything works fine locally, but when I publish the solution to the Azure cloud, I get an error saying it could not find the module/dll: Could not load file or assembly 'LZGEncoder.DLL' or one of its dependencies. The specified module could not be found. Why can't it find the DLL file? is it going to the wrong place or being compiled at all? Is there any way I can check? Thanks! The problem was that the Visual C++ 2010 Runtime

Entry point for C++/CLI x64 WindowsForms App (VS 2015)

白昼怎懂夜的黑 提交于 2019-11-28 11:35:02
问题 I have the same problem as the user in Visual Studio 2015 c++/CLI boost::thread : If I use boost, Windows Forms and C++/Cli together, my app crashes on startup. The proposed solution works for me (change Subsystem to Console); the only small disadvantage is that the console is started alongside the GUI. There is another solution I've found (see https://bytes.com/topic/net/answers/642179-c-cli-winforms-app-native-static-library-singletons-cra) : Changing the entry point to "

Why is “array” marked as a reserved word in Visual-C++?

非 Y 不嫁゛ 提交于 2019-11-28 10:40:18
Visual Studio syntax highlighting colors this word blue as if it were a keyword or reserved word. I tried searching online for it but the word "array" throws the search off, I get mostly pages explaining what an array is. What is it used for? Judge Maygarden It's not a reserved word under ISO standards. Microsoft's C++/CLI defines array in the cli namespace , and Visual Studio's syntax highlighting will treat it as a reserved word. This usage would be considered a vendor extension and not a part of any international C or C++ standard. ISO C99 Keywords: auto enum restrict unsigned break extern