H
h_schmieder
Guest
Hello,
in my C++/Cli project I want to call a delegate from a native Method,
so I have this
//begin from native include
class Reconnecter {
public:
virtual std::string getSAMLResponse() = 0;
};
//end from native include
public delegate String^ SAMLConnectDelegate(String^ url);
class MyReconnecter : public Reconnecter {
public:
MyReconnecter(std::string& _hostname, int port, std::string& _consumer, std::string& _entityid, SAMLConnectDelegate^ _connectdelegate);
~MyReconnecter();
std::string getSAMLResponse();
private:
std::string hostname;
int port;
std::string consumer;
std::string entityid;
msclr::gcroot<SAMLConnectDelegate^> connectdelegate;
};
//Implementation
MyReconnecter::MyReconnecter(std::string& _hostname, int _port, std::string& _consumer, std::string& _entityid, SAMLConnectDelegate^ _connectdelegate)
: hostname(_hostname), port(_port), consumer(_consumer), entityid(_entityid), connectdelegate(_connectdelegate) {
}
MyReconnecter::~MyReconnecter() {
}
std::string MyReconnecter::getSAMLResponse() {
std::string result;
try {
if (connectdelegate != nullptr) {
ServerPool& sp = ServerPool::getInstance();
std::string url = std::move(sp.SAMLCreateAuthnRequest(hostname, port, consumer, entityid));
String^ murl = Helper::ConvertUTF8ToString(url);
String^ samlresponse = connectdelegate(murl);
Helper::ConvertStringToUTF8(result, samlresponse);
}
} catch (...) {
}
return result;;
}
But I get the following errors when compiling;
Error C2088 '!=': illegal for struct
Error C2064 term does not evaluate to a function taking 1 arguments
The first one points to
connectdelegate != nullptr
and the second to
String^ samlresponse = connectdelegate(murl);
If I change the condition to
connectdelegate != __nullptr
I get
Error C2678 binary '!=': no operator found which takes a left-hand operand of type 'gcroot<Jedox:alo::Comm::SAMLConnectDelegate ^>' (or there is no acceptable conversion)
Is there a way to get it working ?
tia
Hendrik Schmieder
Continue reading...
in my C++/Cli project I want to call a delegate from a native Method,
so I have this
//begin from native include
class Reconnecter {
public:
virtual std::string getSAMLResponse() = 0;
};
//end from native include
public delegate String^ SAMLConnectDelegate(String^ url);
class MyReconnecter : public Reconnecter {
public:
MyReconnecter(std::string& _hostname, int port, std::string& _consumer, std::string& _entityid, SAMLConnectDelegate^ _connectdelegate);
~MyReconnecter();
std::string getSAMLResponse();
private:
std::string hostname;
int port;
std::string consumer;
std::string entityid;
msclr::gcroot<SAMLConnectDelegate^> connectdelegate;
};
//Implementation
MyReconnecter::MyReconnecter(std::string& _hostname, int _port, std::string& _consumer, std::string& _entityid, SAMLConnectDelegate^ _connectdelegate)
: hostname(_hostname), port(_port), consumer(_consumer), entityid(_entityid), connectdelegate(_connectdelegate) {
}
MyReconnecter::~MyReconnecter() {
}
std::string MyReconnecter::getSAMLResponse() {
std::string result;
try {
if (connectdelegate != nullptr) {
ServerPool& sp = ServerPool::getInstance();
std::string url = std::move(sp.SAMLCreateAuthnRequest(hostname, port, consumer, entityid));
String^ murl = Helper::ConvertUTF8ToString(url);
String^ samlresponse = connectdelegate(murl);
Helper::ConvertStringToUTF8(result, samlresponse);
}
} catch (...) {
}
return result;;
}
But I get the following errors when compiling;
Error C2088 '!=': illegal for struct
Error C2064 term does not evaluate to a function taking 1 arguments
The first one points to
connectdelegate != nullptr
and the second to
String^ samlresponse = connectdelegate(murl);
If I change the condition to
connectdelegate != __nullptr
I get
Error C2678 binary '!=': no operator found which takes a left-hand operand of type 'gcroot<Jedox:alo::Comm::SAMLConnectDelegate ^>' (or there is no acceptable conversion)
Is there a way to get it working ?
tia
Hendrik Schmieder
Continue reading...