.net - Invoking C++/CLI code from C# -


i have pretty stupid problem: apparently knowledge of .net platform , how c# , c++/cli communicate low, maybe it's don't know lifehacks or need-to-knows of msvs.

i want call c++/cli code c# (an algorithm written native c++ , want wrap it). c++/cli compiles, add reference c++/cli project c# console app project. still doesn`t see it. i've been digging dumb problem half day now. please, help!

and if know theory material cover such gaps in understanding, i'd sincerely - appreciate it. i've read hogenson , used c++/cli glue @ work, have had problems understanding how linker works.

that's solution structure - 1

test.hxx:

#pragma once #pragma managed  namespace test {     class test     {         public:             static int run();     };  } 

test.cxx:

#pragma unmanaged #include <iostream>  #pragma managed #using <system.dll> #include "test.hxx"  namespace test {     int test::run() { return 42; } } 

program.cs:

using system; using system.collections.generic; using system.linq; using system.text; using test;  namespace consoleapplication1 {   class program   {     static void main( string[] args )     {       test.run();     }   } } 

errors:

error   1   type or namespace name 'run' not exist in namespace 'test' (are missing assembly reference?)    c:\users\denis\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\program.cs 13  12  consoleapplication1 

thank help!

i think must define :

public ref class test

in test.hxx


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -