Lukezzz 0 Posting Whiz in Training

I need to convert a C# code into C++. I think I have almost done it except of one line of code wich is this line. First follows the correct C# version but how will that be converted to C++ in bold wich for the moment is wrong ?

(C#)
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback (OnValidateCertificate);

(C++)
ServicePointManager:: ServerCertificateValidationCallback= gcnew RemoteCertificateValidationCallback(OnValidateCertificate);


(Complete C# Code)

private bool OnValidateCertificate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
      return true;
}

RemoteCertificateValidationCallback orgCallback = ServicePointManager.ServerCertificateValidationCallback; 
try 
{ 
	ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback (OnValidateCertificate); 
	ServicePointManager.Expect100Continue = true; 
} 
finally 
{ 
	ServicePointManager.ServerCertificateValidationCallback = orgCallback; 
}

(InComplete C++ Code)

private: bool OnValidateCertificate(System::Object^ sender, X509Certificate^ certificate, X509Chain^ chain, SslPolicyErrors sslPolicyErrors) 
{ 
     return true; 
}

     RemoteCertificateValidationCallback^ orgCallback = ServicePointManager::ServerCertificateValidationCallback; 

     try 
    { 
[B]        ServicePointManager::ServerCertificateValidationCallback= gcnew RemoteCertificateValidationCallback(OnValidateCertificate);[/B]
        ServicePointManager::Expect100Continue = true;
     } 
     finally
     {
        ServicePointManager::ServerCertificateValidationCallback = orgCallback;
     }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.