Click here to Skip to main content
15,886,788 members
Home / Discussions / C#
   

C#

 
GeneralRe: propertygrid double click events Pin
Jone Cunha13-Feb-13 7:32
professionalJone Cunha13-Feb-13 7:32 
QuestionEnevts in MVC application. Need some Help. Pin
plywoods12-Feb-13 21:09
plywoods12-Feb-13 21:09 
QuestionHow to determine whether the given geo code in within geo fence or not? Pin
Vijay Kanda12-Feb-13 20:57
Vijay Kanda12-Feb-13 20:57 
AnswerRe: How to determine whether the given geo code in within geo fence or not? Pin
Pete O'Hanlon12-Feb-13 23:13
mvePete O'Hanlon12-Feb-13 23:13 
Questioncalling a method in c++ from c# Pin
bonosa12-Feb-13 17:45
bonosa12-Feb-13 17:45 
AnswerRe: calling a method in c++ from c# Pin
N a v a n e e t h12-Feb-13 22:19
N a v a n e e t h12-Feb-13 22:19 
GeneralRe: calling a method in c++ from c# Pin
bonosa13-Feb-13 3:55
bonosa13-Feb-13 3:55 
GeneralRe: calling a method in c++ from c# Pin
N a v a n e e t h13-Feb-13 18:21
N a v a n e e t h13-Feb-13 18:21 
Wrapping native objects means, you create a managed class in C++/CLI and hide your hdf_call_vars_t struct inside this managed class. Your library will only deal with this managed object and at the C# side you only have to deal with this managed object. This approach hides all the complexities of using native structs and simplifies your library's interface.

Here is working example of wrapping native object in a managed object.
// ClassLibrary.h

using namespace System;

namespace Example {

	// Native struct
	struct hdf_call_vars_t {
		int foo;
	};

	// This wraps the native hdf_call_vars_t and provides managed class
	public ref class HdfCallVars
	{
	private:
		hdf_call_vars_t* native;

	public:
		HdfCallVars()
		{
			native = new hdf_call_vars_t;
		}

		property int Foo
		{
			int get()
			{
				return native->foo;
			}
			void set(int value)
			{
				native->foo = value;
			}
		}
	};


	// This is your libraries main class
	public ref class YourLibrary {
	public:
		// This method now takes managed objects
		int ReadFile(String^ file_path, HdfCallVars^ ret_vals)
		{
			// your code goes here
			return ret_vals->Foo;
		}
	};
}
To use this library from a C# application,
using System;
using Example;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            HdfCallVars vars = new HdfCallVars();
            vars.Foo = 10;  // Doing native call through well defined interface

            YourLibrary library = new YourLibrary();
            int status = library.ReadFile("filepath", vars);
            Console.WriteLine(status);
            Console.Read();
        }
    }
}


Hope that helps.
Best wishes,
Navaneeth

GeneralRe: calling a method in c++ from c# Pin
bonosa14-Feb-13 16:56
bonosa14-Feb-13 16:56 
GeneralRe: calling a method in c++ from c# Pin
N a v a n e e t h14-Feb-13 21:41
N a v a n e e t h14-Feb-13 21:41 
GeneralRe: calling a method in c++ from c# Pin
bonosa15-Feb-13 17:27
bonosa15-Feb-13 17:27 
GeneralRe: calling a method in c++ from c# Pin
N a v a n e e t h16-Feb-13 17:41
N a v a n e e t h16-Feb-13 17:41 
GeneralRe: calling a method in c++ from c# Pin
N a v a n e e t h17-Feb-13 5:02
N a v a n e e t h17-Feb-13 5:02 
GeneralRe: calling a method in c++ from c# Pin
bonosa13-Feb-13 6:48
bonosa13-Feb-13 6:48 
QuestionDynamic Form Creation/Layout Pin
Matt U.12-Feb-13 4:21
Matt U.12-Feb-13 4:21 
AnswerRe: Dynamic Form Creation/Layout Pin
Orjan Westin12-Feb-13 6:16
professionalOrjan Westin12-Feb-13 6:16 
GeneralRe: Dynamic Form Creation/Layout Pin
Matt U.12-Feb-13 6:51
Matt U.12-Feb-13 6:51 
AnswerRe: Dynamic Form Creation/Layout Pin
PIEBALDconsult12-Feb-13 12:36
mvePIEBALDconsult12-Feb-13 12:36 
QuestionException: Cannot open Servicexxx service on computer 'COMPUTER_NAME' Pin
NarVish12-Feb-13 1:18
NarVish12-Feb-13 1:18 
AnswerRe: Exception: Cannot open Servicexxx service on computer 'COMPUTER_NAME' Pin
N a v a n e e t h12-Feb-13 1:36
N a v a n e e t h12-Feb-13 1:36 
AnswerRe: Exception: Cannot open Servicexxx service on computer 'COMPUTER_NAME' Pin
Dave Kreskowiak12-Feb-13 2:05
mveDave Kreskowiak12-Feb-13 2:05 
QuestionHow can I allow selected rows in a DataGridView (DGV) to be moved up or down in a button click. Pin
susanna.floora11-Feb-13 22:50
susanna.floora11-Feb-13 22:50 
AnswerRe: How can I allow selected rows in a DataGridView (DGV) to be moved up or down in a button click. Pin
Richard MacCutchan12-Feb-13 0:27
mveRichard MacCutchan12-Feb-13 0:27 
GeneralRe: How can I allow selected rows in a DataGridView (DGV) to be moved up or down in a button click. Pin
susanna.floora12-Feb-13 0:56
susanna.floora12-Feb-13 0:56 
Questioncontrol robots with c# !? Pin
ali_heidari_11-Feb-13 21:47
ali_heidari_11-Feb-13 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.