c++-cli

Nuget won't install Entity Framework into C++/CLI project

和自甴很熟 提交于 2019-12-04 11:19:51
I thought this problem was fixed. I'm using Visual Studio 2013 and it is Entity Framework 6.1. I get the error message: PublicKeyToken=xxxxxx is not marked as serializable. I thought this was fixed. Is it broken again and if so, is there a workaround? Thanks. Here is the complete error message when trying to install into a win32 C++ console application. (Built with default settings, no other adds to new build.) Error: Type 'Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim' in Assembly 'Microsoft.VisualStudio.Project.VisualC.VCProjectEngine, Version=12.0.0.0,Culture=neutral,

Universal Windows Platform Apps and C++/CLI (VS 2015 RC1)

*爱你&永不变心* 提交于 2019-12-04 11:10:07
问题 I have some C++/CLI code which derives from the .NET System Namespace classes. Is there a way to reuse this code for Universal Windows Platform Apps? I can't get a reference to the System Namespace in C++, though in C# it is possible. It looks like there is only support for C++/Cx code and not for managed C++/CLI. 回答1: The syntax and keywords of the C++/CX extension resembles C++/CLI a great deal. But that's where similarity ends, they have nothing whatsoever in common. C++/CX gets compiled

Handling Windows Store App exceptions from GetFileAsync

﹥>﹥吖頭↗ 提交于 2019-12-04 10:29:10
I have a problem with the following code example: Windows::Storage::StorageFolder^ location = Package::Current->InstalledLocation; try { task<StorageFile^> GetFileTask(location->GetFileAsync(sn)); GetFileTask.then([=](StorageFile^ file) { try { task<IBuffer^> ReadFileTask(FileIO::ReadBufferAsync(file)); ReadFileTask.then([=](IBuffer^ readBuffer) { // process file contents here }); } catch(Platform::Exception^ ex) { // Handle error here } }); } catch(Platform::Exception^ ex) { // Handle error here } When using a filename that doesn't exist the function throws an exception: Unhandled exception

Calling C code from managed code

六月ゝ 毕业季﹏ 提交于 2019-12-04 10:22:38
I currently have a C function that I'd like to use in .NET (C#). I can see two ways of achieving this: Compiling it (I think this is possible) with /clr on VC++.NET, having implemented "façade" managed methods that call the C code. Compiling the C code as a DLL and then making API calls. What do you find best? How to do the first of them? Update As requested, here is the (only) function I need to call from my managed code: int new_game(double* params1, double* params2); Just one more question (though harder) I have one function of the form int my_hard_to_interop_function(double** input, double

What is the alternative to futures and promises in managed C++

荒凉一梦 提交于 2019-12-04 10:05:16
When compiling managed C++ code with the /clr flag, the compiler does not allow the include. I am trying to port my unmanaged C++ code into a managed C++ environment. I see that C# has the alternatives Task and TaskCompletionSource to replace futures and promises but I do not see these options available in managed C++. I need to perform interop with some C++ unmanaged libraries so I cannot switch to C# completely. I still need a C++ layer in between. How can I achieve future/promise functionality in managed C++? Here is an example of unmanaged code in C++ which compiles without the /clr flag:

Is it possible to get a pointer to String^'s internal array in C++/CLI?

梦想的初衷 提交于 2019-12-04 09:51:07
The goal is to avoid copying the string data when I need a const wchar_t* . The answer seems to be yes, but the function PtrToStringChars doesn't have its own MSDN entry (it's only mentioned in the KB and blogs as a trick). That made me suspicious and I want to check with you guys. Is it safe to use that function? Yes, no problem. It is actually somewhat documented but hard to find. The MSDN docs for the C++ libraries aren't great. It returns an interior pointer, that's not suitable for conversion to a const wchar_t* yet. You have to pin the pointer so the garbage collector cannot move the

Why do we see a ModuleLoadExceptionHandlerException when unit testing

ぐ巨炮叔叔 提交于 2019-12-04 09:29:06
We have a mixed mode assembly that contains both VC++ (using MFC) and C++/CLI classes. It is an MFC Extension dll and is loaded into our MFC executable at runtime and all works well. When we come to unit test the unmanaged classes in there from another C++/CLI assembly, we see the following exception everytime we try to create an instance (via new) of an unmanaged class: Exception System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadExceptionHandlerException: A nested exception occurred after the primary exception

Destructors not called when native (C++) exception propagates to CLR component

≯℡__Kan透↙ 提交于 2019-12-04 08:34:23
问题 We have a large body of native C++ code, compliled into DLLs. Then we have a couple of dlls containing C++/CLI proxy code to wrap the C++ interfaces. On top of that we have C# code calling into the C++/CLI wrappers. Standard stuff, so far. But we have a lot of cases where native C++ exceptions are allowed to propagate to the .Net world and we rely on .Net's ability to wrap these as System.Exception objects and for the most part this works fine. However we have been finding that destructors of

Passing Unmanaged pointers in C++/CLI

陌路散爱 提交于 2019-12-04 08:30:25
I'm creating a C++/CLI wrapper DLL that depends on numerous C++ static libraries. Some of the function calls expect unmanaged pointers to be passed in. How do i pass them properly? Also, other functions expect a "this pointer" to be passed in as a void*. What's the right way to pass "this"? Here's my class definition... public ref class RTPClient { public: RTPClient(); ~RTPClient(); bool Connect(); void Disconnect(); private: CIsmaClient* mClient; }; Here's my usage where the pointers in question are used... RTPClient::RTPClient(): mClient(NULL) { CIsmaClient::Create(&mClient, NULL,

Is it possible to run unmanaged C++ normally from a managed C++/CLI project?

纵饮孤独 提交于 2019-12-04 08:22:34
I'm in the process of wrapping a pure unmanaged VC++ 9 project in C++/CLI in order to use it plainly from a .NET app. I know how to write the wrappers , and that unmanaged code can be executed from .NET , but what I can't quite wrap my head around: The unmanaged lib is a very complex C++ library and uses a lot of inlining and other features, so I cannot compile this into the /clr -marked managed DLL. I need to compile this into a seperate DLL using the normal VC++ compiler. How do I export symbols from this unmanaged code so that it can be used from the C++/CLI project? Do I mark every class I