c++-cli

C++ wrapper class for C# class calling a web service

廉价感情. 提交于 2019-12-12 02:32:50
问题 So, I've written a web service in c#, which has a method for signing a hash. This web service is a WCF Service application. Then, I've created a c# Console application where I've written a function to consume this web service. The declaration of the function which calls the web service is that: class Program { public byte[] callWS(string alias, byte[] myHash,string myPassword) { IhashSignSVCClient client = new IhashSignSVCClient(); byte[] signedData= client.SignandReturn(alias, myhash,

C and hashlib LNK errors

冷暖自知 提交于 2019-12-12 02:25:31
问题 Okay. So i am using Visual Studios 2010 -> Visual C++ and the .NET Framework (Windows Forms Application) and when i try to hash a string with the hashlib++ i get multiple LNK errors. This is hashlib++ : http://hashlib2plus.sourceforge.net/ This is my code for the hash: //I have more Includes but according to http://hashlib2plus.sourceforge.net/example.html these are the only ones required for hashlib++ so these are the ones i am putting on display. #include <string> #include <iostream>

Observer pattern in c++/cli for mixed managed/unmanaged

和自甴很熟 提交于 2019-12-12 02:24:33
问题 I have a system comprising a C# UI, a C++/CLI mixed mode interop wrapper, and some native c++ projects. What I need to do is set up a system such that the native c++ code can send a log message, and the UI can report it. I set up a native IObservable using this as a template, but then the C# code can't be an observer. My thought was to set up another observer pattern in C++/CLI, which observes the native observer, and to let the C# implement that. I used this as a template but I'm struggling

Image resources?

五迷三道 提交于 2019-12-12 02:14:52
问题 I've been struggling for hours trying to figure out how to use resources in C++/CLI. I've messed around with the resource.h/app.rc files along with the managed resx files to no avail. I just have a couple PNG images that I would like to use with a PictureBox, but I can't seem to figure out how to setup the resources... Thanks for your help, Alex 回答1: create a windows forms project add new resource file (resx) to the project open that file, the resource editor appears in the top left corner

Close Current Window when parent UserControl is clicked wpf

无人久伴 提交于 2019-12-12 02:12:31
问题 Right now I have button on a usercontrol. Clicking that button will launch a window as follows, private void Button_Click(object sender, RoutedEventArgs e) { this.Effect = new BlurEffect(); dlg = new WidgetWindow(); dlg.Owner = Window.GetWindow(this); dlg.Show(); this.Effect = null; } Now please see the Image. Whenever I click outside the widget window i.e. anytime I click on the grayed out area of the usercontrol, I want the circular widget window to close. I am trying to raise an event for

Unexpected Stackoverflow exception using CLR in a dll

点点圈 提交于 2019-12-12 01:48:35
问题 I have a software that accepts a C dll as plugin. The dll export two functions: init and quit. To test how the plugin works, I wrote three projects after the NativeWrapper concept: a managed library in C++ (dll), a native wrapper in C++ (also dll, that exports the init and quit functions) and a C++ test program. For now I am just testing the init function. All these are built and run inside VS 2013 without any issue. However, When I plug the two dlls in with the said software, it stops

Why can I declare const structures in C++/CLI, but not in C#?

拈花ヽ惹草 提交于 2019-12-12 01:46:09
问题 I already have found useful answers why it shouldn't be possible at all: Why does C# limit the set of types that can be declared as const? Why can't structs be declared as const? The first one has a detailed answer, which I still have to re-read a couple of times until I fully get it. The second one has a very easy and clear answer (like 'the constructor might do anything, so it had to be run and evaluated at compile time' ). But both refer to C#. However, I am using C++/CLI and have a value

Finalizer Throws Random Exceptions, Raises Random Errors, Hangs App

孤者浪人 提交于 2019-12-12 01:34:09
问题 I have a class in C++/CLI that uses unmanaged resources (a HANDLE for a native thread (i.e. from CreateThread()) and an LPVOID for a fiber from CreateFiber/ConvertThreadToFiber). Under the advice I got from MSDN I'm cleaning up the unmanaged resources in the finalizer (!Fiber()), and the destructor (~Fiber()) is calling the finalizer. Here's the code: Fiber::~Fiber () { this->!Fiber(); } Fiber::!Fiber () { if (thread!=NULL) { delete thread; thread=NULL; } if (fiber!=NULL) { DeleteFiber(fiber)

GCC support for C++/CLI

泪湿孤枕 提交于 2019-12-12 01:18:30
问题 Does somebody know, are there any plans or works to add ECMA standardized C++/CLI language support to GCC (which would emit IL code)? This question was partially discussed in SOF (Does Mono .NET support and compile C++ / CLI?), but firstly I'm not sure that this imaginary project should be realized as a part of Mono project instead of core GCC one, and secondly I'm interested in novel information on this subject. 回答1: I know of no such work personally (and my opinion of most ECMA standards

C++/CLI: return a reference to unmanaged object

杀马特。学长 韩版系。学妹 提交于 2019-12-12 01:07:57
问题 I'm looking for a way to return the reference to another object that is a member of a managed object. This can be easily achieved in C++, but is a challenge for C++/CLI wrapper to be used with C#. Below is reproducible scenario (it's a lot of code, but it's all very easy, just demonstrating the problem) C++ classes: class NATIVEAPI NativeSlave { public: NativeSlave() : x_( 0 ), y_( 0.0 ) {} NativeSlave( int x, double y ) : x_( x ), y_( y ) {} int x_; double y_; }; class NATIVEAPI NativeMaster