c++-cli

Getting error C3352 (specified function doesn't match delegate type), even though function seems to match delegate type

六月ゝ 毕业季﹏ 提交于 2019-12-09 03:18:08
问题 Here is the exact error message on compilation: error C3352: 'double MyNamespace::MyRefClass::MyFunction(const std::vector<_Ty> &,std::vector<_Ty> &,void *)' : the specified function does not match the delegate type 'double (const std::vector<_Ty> &,std::vector<_Ty> &,void *)' MyFunction is a private function in the reference class MyRefClass The quoted error shows up when I try to create an instance of the private delegate MyDelegate , declared in the same reference class, with the code:

How to use managed code from unmanaged code?

蹲街弑〆低调 提交于 2019-12-09 00:04:43
问题 How do I call a .NET code from native C++ (unmanaged code)? I want to expose .NET code to my unmanaged (C++) application and then use them. More specifically, I want to call C# from native C++ :). I know there are many ways but can you tell me the pros and cons of each? By the way, I don't want to use COM so what are the options now? Is it possible that I wrap the C# code in C++/CLI and then call it from C++? If so, how do I do that? How do I wrap the C# in C++/CLI and then call it from C++?

wrapper to c++/cli

让人想犯罪 __ 提交于 2019-12-08 23:34:30
What is the basic structure of a wrapper to c++/cli so it can be called from c# ? A wrapper for a C++ class Blah: EDIT: ref class BlahWrapper { BlahWrapper () { blah = new Blah(); } !BlahWrapper() { //Destructor called by GC if (blah != null) { delete blah; blah = null; } } ~BlahWrapper() { //Dispose() called in "using" blocks, or manually dispose if (blah != null) { delete blah; blah = null; } } private: Blah* blah; } 来源: https://stackoverflow.com/questions/4985907/wrapper-to-c-cli

Add a customized header to WebBrowser control for all requests in C++/CLI?

拈花ヽ惹草 提交于 2019-12-08 22:34:28
I'm trying to reproduce this C# workaround in C++/CLI, but it doesn't work, here's my code: private: System::Void WebBrowser1_Navigating(System::Object^ sender, System::Windows::Forms::WebBrowserNavigatingEventArgs^ e) { System::Diagnostics::Debug::WriteLine("Running..."); auto activeXInstance = (SHDocVw::IWebBrowser2^) this->webBrowser1->GetType()->InvokeMember("ActiveXInstance", System::Reflection::BindingFlags::GetProperty | System::Reflection::BindingFlags::Instance | System::Reflection::BindingFlags::NonPublic, nullptr, this->webBrowser1, gcnew array<System::Object^>{}); System:

Passing pointer from managed C++/CLI to ActiveX C++ component

一笑奈何 提交于 2019-12-08 20:58:26
I have an ActiveX component built in C++. One of its methods has this signature: short Component::Method(short FAR* ptr) {} When the I add the ActiveX into my C++/CLI application the method signature shows as: short Compnenet::Method(short% ptr) {} I want to be able to correctly pass short* pSomething; variable value to this method. of course, the new signature doesn't accept passing arguments as short* and even if you try to cast to short% it doesn't give right results. Note: I don't have access to the activeX control to change. I can only confirm the value of address that that the activeX

C++/CLI: Is overloading on return type only possible?

本秂侑毒 提交于 2019-12-08 20:57:33
If I understand well, in C#, it is possible to do public class X : ICloneable { public X Clone() { ... } object ICloneable.Clone() { return Clone(); } // This calls the above } according to this thread . This kind of overloading is forbidden in C++, since it only depends on the return type. Now, I would like to do this exact thing with ICloneable in C++/CLI. Is there a way ? This type of overloading is allowed in C# not because of different return type, but because of explicit implementation of interface - ICloneable.Clone . About C++/CLI look here: http://msdn.microsoft.com/en-us/library

Embedding resource in a C++/CLI project

家住魔仙堡 提交于 2019-12-08 19:47:58
问题 I'd like to embed some files (text files, maybe graphics) in a C++/CLI project -- preferably the same way I can do in C# project. This might be however impossible, as I found in this post: http://bytes.com/topic/net/answers/571530-loading-markup-xamlreader-load-resource-file#post2240705. This was written three years ago, so maybe now there is some way to do this (in VS2k8)? 回答1: Under C++/Cli project go to “Properties…”, then look under “Linker”, and then “Input”, you’ll see the list of

Why is Visual Studio 2010 pretty-printing in C++ mode while stepping through C# code?

橙三吉。 提交于 2019-12-08 17:20:49
问题 I am encountering a strange issue. i have all the latest updates in my PC. My OS is Windows 7. Can anyone help me out with this? I have tried resetting the Visual studio. And here is the exact problem blown up to make it easier to see: 回答1: The Hex display is because you chose that option (clicked on the toolbar), click on it again to switch back to the normal display. The C++/CLI type is not related to the Hex dispaly issue though. 回答2: I had the exact same issue. To confirm, look in the

Unmanaged to managed callback much slower when target is in another AppDomain

时间秒杀一切 提交于 2019-12-08 16:56:50
问题 I'm calling managed code from unmanaged code using a delegate. When I call into managed code in the default AppDomain I'm measuring an average of 5.4ns per call. When I calling to a second AppDomain I'm measuring 194ns per call. (default VS2017 x86 release configuration, not running under the debugger). Why is performance so much lower when calling into an AppDomain that isn't the default? Since I'm coming from the unmanaged side, which has no knowledge of AppDomains I would expect to be

Add acroform with pdfsharp

半城伤御伤魂 提交于 2019-12-08 16:53:23
问题 how can i add Acroforms (or any inputfields) with pdfsharp lib to a pdf? For example a textbox (PdfSharp::Pdf::AcroForms::PdfTextField) I can't find any example for this, only read/modify. I found "page->Elements->Add(key,pdfitem)", but i cant create a Object from PdfSharp::Pdf::AcroForms::PdfTextField or the others Forms (no Constructor) 来源: https://stackoverflow.com/questions/25222759/add-acroform-with-pdfsharp