質問

I have a web form, that when submitted goes to a web service and logs the form data in a database. It then returns back to the web control, where after a few checks it then goes back to the web service and sends out an email to a pre specified email address. I've compiled the code without error, however when I try and execute the code, I have an issue with a NotImplementedException after the data has been stored in the database and I try to go to the CreateEmail method to start the process of sending the email.

After reading these:
http://msdn.microsoft.com/en-gb/library/system.notimplementedexception.aspx What does "throw new NotImplementedException();" do exactly?
Why does NotImplementedException exist?

I realised that it's saying that my method has not been implemented or does not exist.

Visual Studio is picking up the method and displaying it in it's intellisense, and the method does contain code, which I have included in a very basic cut down way below.

I have a connection set up higher in the same method, called "service" which I know is working as it connects to my service in order to store the data in the database.

I've checked that the operation contract is in place:

[OperationContract]
string CreateEmail(string name, string address, string town, string postcode, string email, string contact); 

I have the following code for going to my service from my web form:

if (DBresults == "0")
            {
                try
                {


                    EmailResults = service.CreateEmail(name, address, town, postcode, email, contact);
                }
                catch (NotImplementedException ex)
                {
                    service.Abort();
                }
                catch (CommunicationException ex)
                {
                    service.Abort();
                }
                catch (TimeoutException ex)
                {
                    service.Abort();
                }
                catch (Exception ex)
                {
                    service.Abort();
                    throw ex;
                }
}

Then within the web service itself I have the following code (I've altered the names for ease, and removed the main body of the try for easy reading):

namespace WcfSvc{

public class WcfSvc : IWcfSvc
{

public string CreateEmail(string name, string address, string town, string postcode, string email, string contact)
    {

        string sent = "1"; 
        string fromEmail = "test@test.com";

        try
        {
            //main bit of my sent code. 
            string sent = "done"; 

            return sent; 
        }
        catch (Exception ex)
        {
            string exMessage = ex.Message;
            ex = null;
            return exMessage;
        }

    }
}
}

I've tried to put a breakpoint in the service on CreateEmail, but it never hits it, instead going straight to the catch error.

Where am I going wrong?

Edit:

The exception message that I get is: ex = {"The method or operation is not implemented."}

役に立ちましたか?

解決

Verify that the web.config or app.config contains the right web address for the latest web service. Test the call to the web service with the WCF test client. Verify that the process running the service has up to date code.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top