c++-cli

How to terminate .NET application on a specific exception - possibly without stack unwinding?

送分小仙女□ 提交于 2019-12-13 02:24:29
问题 I have a .NET application (service) that consists of C# and C++ code. "Crashes" (i.e. System.AccessViolationException and other Corrupted State Exceptions) in the C++ Code will be ("non-") handled correctly, they will directly lead to my AppDomain.CurrentDomain.UnhandledException handler (which logs) and then the application will terminate, writing a WER dump file if so configured (which it is). For this application, I have determined that System.NullReferenceException is always a bug,

C++ CLI: cliext::vector<T> as return type of public class function?

感情迁移 提交于 2019-12-13 02:17:17
问题 I have next class in C++ CLI: public ref class MyClass { public: MyClass(void); virtual bool Init(); cliext::vector<int>^ ListOfNumbers(); }; I would like to recive vector of int from public fucntion. Here is impl: cliext::vector<int>^ MyClass::ListOfNumbers() { cliext::vector<int>^ devs = gcnew cliext::vector<int>(); devs->push_back(1); return devs; } My problem is that I got next warning: warning C4677: 'ListOfNumbers': signature of non-private member contains assembly private type 'cliext:

multi-file c++/cli .net assembly in ASP.NET web site

假如想象 提交于 2019-12-13 01:00:24
问题 I have a .NET assembly that I want to use in an ASP.NET web site. The assembly has the following characteristics: written in C++/CLI contains managed and unmanaged code compiled to x86/x64 platforms (using the correct platform-specific assembly, so it's not believed to be an issue here) compiled as a multi-file assembly linking several native dlls When I try to compile I am getting an error stating: Could not load file or assembly '...' or one of its dependencies. An attempt was made to load

Decimal to Hexadecimal Functions in C++/CLI

我们两清 提交于 2019-12-13 00:44:00
问题 I have a program that communicates to a device through the serial port. I am having difficulties with one section however. I am getting what looks like a right angle symbol when I run through the calculated hexadecimal commands. Here are the two sections of code (main section and function). Main Section: private: System::Void poll_Click(System::Object^ sender, System::EventArgs^ e) { int i, end; double a = 1.58730159; String^ portscan = "port"; String^ translate; std::string portresponse [65]

C++/CLI: is it possible to target the .NET 3.5 Client Profile using Visual Studio 2008?

二次信任 提交于 2019-12-13 00:23:56
问题 I have a C++/CLI library that I'd like to target the .NET 3.5 SP1 Client Profile, but the client profile does not appear in the list of available frameworks. Is it possible to do this? 回答1: It's possible – if not through the UI, then at least by manually editing your App.config file: <?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v2.0.50727" sku="Client" /> </startup> </configuration> Edit your App.config file so that its supportedRuntime element

Including windows.storage.streams.h

你。 提交于 2019-12-13 00:08:48
问题 I'm trying to put class NativeBuffer from this answer but when windows.storage.streams.h I have much errors like: Error 1 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 75 Error 2 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 76 Error 3 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 77

How to trim an array in .NET?

大城市里の小女人 提交于 2019-12-12 21:22:16
问题 Say I have an array array<double>^ buffer = gcnew array<double>(100); And I want a function that does something like: void foo(array<double>^% buffer) { Array::Resize(buffer, 10); } but that don't allocate and/or move &buffer[0] when you want to trim the array. 回答1: .NET arrays are immutable in size once created. You can't trim it; you must reallocate and copy. So Array.Resize already does everything you need. Perhaps just ignore the elements at the end if you really don't want to do this. Or

Solving circular project dependency between C# and C++/CLI projects?

感情迁移 提交于 2019-12-12 17:20:57
问题 We have a solution with a number of projects. In one particular case, we have two projects: 1) A C# project that does most of the work 2) A C++/CLI project that acts as a go-between to some native C++ code The C# code calls into the C++ wrapper, all is well. However, there is some new functionality that we are pulling in. On the managed side of the C++ wrapper (project #2), it requires some static methods in the managed C# code that is in project #1. However, Visual Studio will not let us

LNK 2022: Inconsistent layout information, after migrating to VS2010

自古美人都是妖i 提交于 2019-12-12 16:09:02
问题 I have a VS2010 solution that contains (among others), the following projects: Native.DLL (native C++ project that statically links to a third party lib, ITK, which includes STL) Pseudo-code (very simplified): using namespace std; bool Native::CalcSomething(double* result, string& errorMsg); Wrapper.DLL (C++/CLI project that dynamically links to Native.DLL and uses std:string in a call to the Native.DLL) Pseudo-code (very simplified) bool Wrapper::WrappedCalcSomething([System::Runtime:

c++/cli Explicit implementation of interface overrides

徘徊边缘 提交于 2019-12-12 16:07:18
问题 I have two interfaces: public interface I1 { A MyProperty { get; set; } } public interface I2 : I1 { new B MyProperty { get; set; } } In C# I can explicitly implement like this: public class C : I1, I2 { public B MyProperty { get; set; } A I1.MyProperty { get; set; } } Somehow I have to use these interfaces in a c++/cli project. So, how can I implement this in c++/cli? Thanks in advance. 回答1: I solved it myself. It should be: public ref class C : I1, I2 { public: virtual property B^