I have a application in which has following component -
PushManager - This solution contains a class in which C++ DLL(PushCommon) is Imported using DllImport().
PushCommon - This soultion receives data from PushManager processes it and returns output.methods written in this solution are all exported.
Now requirement I got is call one of the method in PushManger in PushCommon.
I am not sure how I it can be done.
So I am here to get advice from the experts here.
Not following completely. Please fill in the blanks:
C++ Side:
Project Name or DLL name: _______________
Does it export functions or does it export objects?___________
What are the names of the exported functions or objects?____________
C# Side:
Project Name:____________________
Does it export anything? If yes, what?_______________________
Project Name or DLL name: ___PushCommon.dll____________
Does it export functions or does it export objects?____Functions_______
What are the names of the exported functions or objects?____ProcessData()________
C# Side:
Project Name:________PushManager____________
Does it export anything? If yes, what?_______It doesn't exports anything________________
Awesome. Thanks. What you describe is a typical P/Invoke scenario.
Assuming you used extern"C" when exporting the ProcessData() function, all you would do in C# is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
publicstaticclass PushCommon
{
[DllImport("PushCommon.dll")]
externpublicstatic <return type> ProcessData(<list of parameters>);
}
...
//And now you just use it.
publicclass Program
{
publicstaticint Main(string[] args)
{
PushCommon.ProcessData(<list of arguments here>);
return 0;
}
}
I am having a similar problem, and i have been looking for this for days. can someone help me solve my problem. I have a C++ program and i created a DLL out of it.
I have another C# forms application, and i added the DLL as 'add reference'. when i double click on this DLL, i get the 'Object Browser' and when i expand the '+' sign i don't see any of my member functions that i wrote in it.
example.h
1 2 3 4 5 6 7 8 9 10 11 12 13
#pragma once
usingnamespace System;
namespace example {
public ref class Class1
{
public:
// TODO: Add your methods for this class here.
int main1(void);
};
}