Hi, i am working on a project using C and C++.
But now i have to use lil bit of C# code in it.So i made a sample application , converted all the c# code to managed C++/CLI.I changed the properties of sample app to Clr support.It worked fine.
But in my current project, i have some pure c classes also. So when i was changing the property of my project to CLR , it gave me error of xyz.c file cannot convert into \clr.
I dont know wat to do?i cannot convert xyz.c class into xyz.cpp
Can anyone suggest what should i do... Is it possible that i mange to use mannaged c++ also and i still donot have to convert the whole project into CLR.
Hi,Thanks for the reply.
I managed to do it by adding a new CLR class and putting all my C Sharp code to it.Automaticaly VS
ask me that wether i would like to convert by my code to CLR.Then it converts all my code to CLR without giving any compile error .
Hi Richard .. I posted my problem i tried diffrent ways to solve it..like i told you that i found a temporary way to resolve my problem.
But that is not proper solution.
You know what that now i am thinking to use my CLI/C++ code as dll .To call the function in that dll, do i need a wrapper class in my unamanged c++ code .If yes then can you give me an idea or post to implment it.I havenot used wrapper classes before.
Is there any other way to call dll functions.Need your guidance.Thanks in advance.
As I suggested before, you could just make all your unmanaged copde into a standard DLL. You can then access the functions directly via P/Invoke[^]. I am not exactly sure what you are trying to do with the C code, and whether it would not be better just to convert it all to C#.
Hey i dont think ,i made my point clear to you.Actually this thing is completely new to me.Thats why i am unable to explain it corectly.
I have unmanaged c++ code.
But now in that i need to use some of the managed i.e C++/CLI code.
That is my main problem .
I tried to search solutions on internet but these solutions made me more confused.
One of the solution said , i should make dll of the managed code .Then i should make one wrapper to call the functions of the dll.Should i do that.
Can't i directly use the functions of dll in my c++ unmanged code like withe help of GetProcAddtress()
without any wrapper class.I am new to all this.
I'm afraid it is still not clear exactly what you are trying to do and why you need to mix managed and unmanaged code. I have already explained that you can use the functions of an unmanaged DLL in managed code by using the P/Invoke mechanism (link given in my previous answer). If that does not, or will not work, then you need to give an example of your code and explain what the problem is.
Okay , i will tell you.What is my problem.
Actually i need to use powershell apis , in my c++ code.As i need to find out the no .of servers in my appfabric cluster.
So the challenge was how to acess powershell in c++ code.
I had one c# code in which i was able to acess powershell properly.
It gives me every information i need to find out..Like wether the appfabric service is running or not.How many servers in cluster.All the info.
Now as my code is in c++ , my biggest challenge is using the c# script in c++,because that
scripts works wonder for me.
So to use that i converted whole of C# code into C++/CLI so that i can use it in my current unmanged c++ code.
Now the problem is adding that C++/CLI code into UNMANAGED CODE so that i can acess powershell in c++.
How to do that mixed mode programming?