The C++/CLI wrapper method will be accessed from C# as follows:
string x="some value", y="another value", z="a third value";
managed.ManagedMethod( x, y, z );
The problem I am having is converting the managed string handle (String^ y) to an unmanaged VARIANT parameter. I would like to be able to solve this problem without having to modify the unmanaged C++ code. Does anyone have any suggestions or ideas on how to do this?
Sure but my level of apathy for people writing production code that can't blow their own nose is fairly high today.
I feel like starting a new CodeProject account with the user name "HellNo" for replying to all the "can you provide the code" lovelies. Or maybe I shoudl write a programming book titled "Copy Paste for Idiots"... wait...
Copy the following code and paste it into your code file at the appropriate location:
<code>int n = 11;</code>
Now modify the code until it produces the desired results.
There finished... now all I need is to send it off to a publisher.
could you provide some sample code of how to do this? I thought of doing that, but I couldn't get it to work.
Since you've already written code to convert String^ to BSTR, I presume your problem is with converting that to a VARIANT. To do that, you can use _variant_t which has a constructor that takes a BSTR, and use that. You can pass _variant_t anywhere a VARIANT is expected.
I have a simple DLL file that performs an smtp email function for one of my applications. The problem with the DLL is - it sends an OK dialog box to the user once the email has successfully been sent. I was wondering if it were simple enough for you to remove the OK dialog box from the DLL.
If successful the OK dialog box should not appear after the email has been sent.
Can a DLL be changed like this, or do I have to create a new one altogether?
Independant programmer for small business. Client management solutions
I have posted this under Visual Studio too as i was unsure of the correct fourm.
I have a Crystal Report 10 report which i need to use in my app. I use Managed solution for this. There are no compiler or linker problems. I am not able to display this report on the screen but am able to print the report. I tried all member methods - Visible, Show, BringToFront, set_Size etc. Am i missing something.?
Here is the code snippet for your ref:
crReportDocument = new ReportDocument();
// MessageBox("Report Document Instance Created", "New Reports");
// MessageBox("File Loaded to Report Document Instance ", "New Reports");
//Setup the connection information structure to be used
//to log onto the datasource for the report.
crConnectionInfo = new ConnectionInfo();
// MessageBox("Connection Info set", "New Reports");
//Get the table information from the report
Hi i've been struggling for two days now, the Client Server application I wrote runs perfect when my pc runs the server and the other pc connect to it. but if i change the host ip on the client program and run the server on any other pc I get the the
SocketException : No connection could be made the target machine activly refused it
I've tried every thing even removed the firewall's on all the comuters
can any one help me...?
OK. So I'm trying to create a custom control in a C++/CLI project. I create it, build it, it gets added to the Toolbox, everything is happy -- until I try to add the control to a Windows form. As soon as I drag the custom control from the toolbox to the form, I get the message "Failed to load toolbox item <insert name here>. It will be removed from the toolbox."
So I took a "back-to-basics" approach and tried to create a user control that merely encapsulates a textbox. Nothing else added. Just a plain old text box. I get the same $@#$@#%!#% message.
So at this point I figure either I'm just stupid or else there's something seriously wrong with my installation of Visual Studio (2005 Professional). Can someone point me to a good step-by-step article on creating custom user controls specifically in C++/CLI? Or does anyone have an idea why I'm getting this message?
Just wanted to follow up with you. Thanks for that sample project. At first glance, it appeared I was doing everything correctly, but a little deeper digging revealed the problem: My project is built with the /clr option rather than /clr:pure. Once I moved my custom control into a separate DLL project built with the /clr:pure switch, I was able to bring that control into forms in the main project with no problem.