Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6948057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:46:22+00:00 2026-05-27T13:46:22+00:00

Okay, I have a WCF service which is going to be acting as a

  • 0

Okay, I have a WCF service which is going to be acting as a way to access my SQL database. That part has become largely irrelevant to this question, since for some reason my WCF service crashes. Or, at least, it causes my client Silverlight application to crash. This is why I come here to ask you guys about it.

So here’s the code. Bear in mind that it is called asynchronously from my Silverlight client. When it is done, the string that is returned from this method is put on the screen for the client.

public string AddClients(IEnumerable<Client> newClients)
    {

        int nAdded = 0;
        int nelse = 0;
        string str = "";

        List<Client> newClientsList = newClients.ToList();
        List<Client> existingClients = dc.Clients.ToList();
        List<Client> clientsToAdd = new List<Client>();

        return newClientsList.Count.ToString();


        foreach (Client client in newClientsList)

        {
            var clt = existingClients.FirstOrDefault(c => c.ClientName == client.ClientName);

            if (clt == null)
            {

                return clt.ClientName;

                //str = str + " found:  " + clt.ClientName + "\n";
                //dc.Clients.(clt);

                //existingClients.Add(clt);
                //  clientsToAdd.Add(clt);

                nAdded++;
            }
            else
            {
                nelse++;
            }
        }

        if (nAdded > 0)
        {
            //str = str + "  more than one nAdded";
            //    dc.Clients.InsertAllOnSubmit(clientsToAdd);
           //    dc.SubmitChanges();
        }

        return nelse.ToString();

    }

You may be able to figure out what’s supposed to be happening, but most of it’s not happening now due to the fact that it’s not working out for me very well.

At the moment, as you can see, there is a return quite early on (before the foreach). With things as they are, that works okay. You press a button in the client, it makes the call, and then returns. So as it is, you get ‘3’ returned as a string (this is the size of newClients, the parameter). That is okay, and at least proves that the service can be connected to, that it returns messages okay, and what not.

If I remove that top most return, this is where it gets interesting (well, problematic). It should either return clt.ClientName, in the if (clt==null) condition, or it should return nelse.ToString() which is right at the end.

What do I actually get? Nothing. The method for the completion never seems to get called (the message box it shows never appears).

I’ve commented most of the stuff out. Surely it has to get to one of these conditions! Have I missed something really obvious here? I really have been attempting to debug this for ages, but nothing! Can someone see something obvious that I can’t see?

For the record, ‘dc’ is the data context, and dc.Clients is a list of Client entities.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:46:22+00:00Added an answer on May 27, 2026 at 1:46 pm

    I could be missing something, but won’t this throw a NullReferenceException? That has to be at least part of your problem.

    if (clt == null)
    {
        return clt.ClientName;
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I've got this WCF service going. It has a public access, which is
So, I have a WCF service that is listening on both net.tcp and net.pipe.
Okay i have a custom server control that has some autocomplete settings, i have
I have a method in a WCF service which returns a complex type (myComplexResult),
Okay, so I have a LINQ to SQL system set up on a WCF
Okay so I have a WCF service writing to the Event Log. All is
I have set up a WCF service on a server which lives in its
Okay I have a large CRUD app that uses tabs with Forms embedded in
Okay I have a series of objects based on a base class which are
okay i have found the way to run a video in a image.... the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.