Tuesday, August 4, 2009

'CertificatePolicy is obsoleted for this type

Error message: 'System.Net.ServicePointManager.CertificatePolicy' is obsolete: 'CertificatePolicy is obsoleted for this type, please use ServerCertificateValidationCallback instead.' http://go.microsoft.com/fwlink/?linkid=14202

ServicePointManager.CertificatePolicy = new CustomCertificatePolicy();

modify to

ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(CertValidation);

bool CertValidation(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslpolicyErrors)
{
bool result = false;
// TODO: implement
return result;
}

for example if you want to accept untrusted server certificate which I don't recommend :D use it like:

bool CertValidation(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslpolicyErrors)
{
bool result = false;
if ((chain != null) && (chain.ChainStatus.Length == 1) &&
(chain.ChainStatus[0].Status == X509ChainStatusFlags.UntrustedRoot))
result = true;
return result?result:sslpolicyErrors == SslPolicyErrors.None;
}

Monday, June 22, 2009

Thread was being aborted.

System.Threading.ThreadAbortException: Thread was being aborted.
occured on Response.Redirect(url) even when in a try catch block.

Asp.net framework catches the Redirect method's exception, aborts the thread and use a new thread for execution of the redirected page. This occurs when using the second argument of Redirect method as True, because this means to asp.net framework something like 'Stop this page's execution ASAP and execute to be redirected page'.

Response.Redirect method internally calls Response.End method which raises this exception and the page processing terminates. Response.End raises this exception indirectly through calling Thread.Abort which raises this exception directly.
When this exception occurs you can catch it in a catch block of a try...catch structure. The exception will be raised again by the runtime at the end of the catch block. So, no use of the try...catch block.

try to use Response.Redirect(url, false)

source http://p2p.wrox.com/asp-net-1-0-1-1-basics/5684-thread-being-aborted.html

Wednesday, January 14, 2009

Inexact float


I've found nothing to do about it.