0

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."}

Community
  • 1
  • 1
hlh3406
  • 1,382
  • 5
  • 29
  • 46
  • Put a breakpoint on string sent = "1"; and from there work your way through the execution. See if anything unexpected happens because the problem appears to be in your CreateEmail method. Also, what is EmailResults? – Matthijs May 14 '14 at 13:34
  • I would recommend that you look at using a 'finally' block for the 'service.Abort()' call. Read about it here: http://msdn.microsoft.com/en-us/library/dszsf989.aspx – ctrlplusb May 14 '14 at 13:36
  • Hi @Matthijs I've tried that, I get a yellow message that says: "The breakpoint will not currently be hit. No symbols have been loaded for this document." – hlh3406 May 14 '14 at 13:37
  • Check the stack trace to see where the exception was been generated. It could be inside your "main bit of my sent code". – sergiogarciadev May 14 '14 at 13:38
  • Can you give the errorinformation? The catch you get should receive an error. Write it to a log and copy-paste it into your question, please, thanks – Matthijs May 14 '14 at 13:39
  • You need to attach to the correct process to debug the wcf service. Are the deployed version of the service the same as the one you are viewing in visual studio? Are you running the wcf service in IIS or the built-in webserver in VS? Forgot to update the assembly(dll) after rebuild? – scheien May 14 '14 at 13:39
  • Hi @scheien, I have updated my dll file on the server after rebuild and republished my service to the server as well. – hlh3406 May 14 '14 at 13:45
  • @hollie3406 - And you are sure that the assembly is the correct version? Check the assembly with reflector/ilspy if you are not sure. You could also try to recycle the applicationpool, but that should be done automatically when you deploy new assemblies. – scheien May 14 '14 at 13:48
  • Hi @scheien I've not used reflector/ilspy before, but I am able to navigate to a web based XML file after I've published my service, and the method shows up there. I'll try and recycle the application pool and see if that helps. – hlh3406 May 14 '14 at 13:56

1 Answers1

1

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.

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122