Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
|
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2008, 04:00 AM
Authorized User
 
Join Date: May 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default v urgent..Error: not all code paths return a value

Hi..when i am trying to execute the code..its giving the following error:
'PublicServices.GetSignature(string, string)': not all code paths return a value.
the code is:

[WebMethod]
    public string GetSignature(string AccessKeyID, string content)
    {
        try
        {
            if (AuthorizeUser(AccessKeyID) == false)
            {
                return "";
            }
            Encoding myEncoding = new UTF8Encoding();
            // Create a new Cryptography class using the
            // Secret Access Key as the key
            HMACSHA1 myCrypto = new HMACSHA1(myEncoding.GetBytes(mySecretAccessKeyId)) ;
            // Calculate the digest
            byte[] strDigest = myCrypto.ComputeHash(Convert.FromBase64String(cont ent));
            return Convert.ToBase64String(strDigest);
        }
        catch (Exception ex)
        {
            sendException(ex);

        }
    }

public void sendException(Exception ex)
    {
       SendMail("[email protected]", "[email protected]", "errorhandling", "error occured" + ex.StackTrace + "\r\n" + "\r\n" + "error description :" + ex.Message.ToString() + "\r\n" + "\r\n" + "error generated time :" + System.DateTime.Now);
    }
public bool SendMail(string from, string to, string subject, string body)
    {
        try
        {
            SmtpClient mailObj = new SmtpClient();
            mailObj.Host = "mail.retgdsg.com";
            MailMessage msg = new MailMessage(from, to, subject, body);
            msg.IsBodyHtml = false;
            mailObj.Send(msg);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }

could any one help me...in this regard.

 
Old May 20th, 2008, 06:17 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The error means what it says - Not all code paths return a value.

If an exception is thrown inside the try/catch, then the execution will pass to the catch part of the code. From here to the end of the function there is no return statement. You either want to return null, or rethrow the exception.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
not all code paths return a value galua SQL Language 11 January 20th, 2008 09:36 PM
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
not all code paths return a value c# awaisfaisal C# 5 May 10th, 2007 08:02 AM
How to return "0" instead of #Error guizero Access 9 June 2nd, 2006 12:52 PM
Code to Remove Carriage Return From Spreadsheet Jersey Eric Excel VBA 2 May 12th, 2005 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.