I have created C++/CLI wrapper for calling C# dll methods and events.I have referenced C# dll in the C++/CLI wrapper project.I have called connect1 method which consists of colorinitialize() and colorclientconnect() both have to be called from C# dll.The following code i have used for calling C# dll with in C++/CLI wrapper.
NativeInterface.h
extern "C"{
__declspec(dllexport) const char* Connect1(char* str, int port);
__declspec(dllexport) const char* Test(char* str, int port);
};
SampleWrapper.cpp (C++/CLI wrapper)
#include "NativeInterface.h"
namespace Wrapper
{
#ifdef __cplusplus
extern "C"
{
#endif
__declspec(dllexport) const char* Test(char* str, int port)
{
KinectV2Server::KinectV2 c1;
c1.GetBytes();
return str;
}
__declspec(dllexport) const char* Connect1(char* str, int port)
{
KinectV2Server::KinectV2 c1;
c1.ColorInitialize();
c1.ColorClientConnect(gcnew System::String(str));
return str;
}
#ifdef __cplusplus
}
#endif
}
After that i will call this C++/CLI wrapper in another C++ application like this,
C++ application:
#include "SampleCPlusApps.h"
#include <math.h>
#include "Time.h"
#include "NativeInterface.h"
SampleCPlusApps::SampleCPlusApps(void)
{
float smoothing = 0.7f;
float correction = 0.3f;
float prediction = 1.00f;
float jitterRadius = 1.0f;
float maxDeviationRadius = 1.0f;;
fde.Init(smoothing, correction, prediction, jitterRadius, maxDeviationRadius);
}
int SampleCPlusApps::Initialization()
{
const char* test;
test = Connect1("197.1.1.1",1524);
}
so from my above code, i have doubt in SampleWrapper.cpp (C++/CLI wrapper).Here i have declared my c# dll(KinectV2Server::KinectV2 c1) inside the method.
But i need to declare the c# dll globally, so that it can be used in both functions namely connect1 and test.
Please assist me to fix the issue.
Thanks