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 7084809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:20:52+00:00 2026-05-28T07:20:52+00:00

I have an application that uses Monotouch/C# on the Mac as the front end,

  • 0

I have an application that uses Monotouch/C# on the Mac as the front end, pulling data from a WCF service in VS2010 on the backend. Everything was working like a dream last night before I left, and today, I’m not sure what’s going on. All I can see is that it’s an exception coming from within Monotouch’s linq, and it looks like I’m doing everything OK, as I haven’t touched this piece of code in the last few days.

After I get a GetAllStaffResult object back from WCF, I get myself back into the main thread and then call this method Populate():

public void Populate()
{
    foreach (var m in Staff)
    {
        m.FranchiseName = this.Franchises.Single(f => f.ID == m.FranchiseID).Name;
    }
    [snip]
}

Here’s the stack trace:

System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Linq.Enumerable.First[FranchiseListingItem] (IEnumerable'1 source, System.Func2 predicate, Fallback fallback) [0x0004a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:816
at System.Linq.Enumerbale.First [FranchiseListingItem] (IEnumerable'1 source, System.Func2 predicate) [0x00007] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:843
at ADMobileServices.BOTransferDTOs.GetAllStaffResult.Populate() [0x0003b] (my code)

Not sure what could be causing this… anyone have any ideas? Going to see if I can find MT source files so I can see those lines.

Oh, this is a GetAllStaffResult, the method above is a partial class which has an array of staff members, franchises, locations. The populate method takes each staff member and populates the name of the franchise based on the staff’s franchise ID. I’m doing this because I’m returning like 500 staff members with long franchise names and I’m saving bandwidth by reconstructing the object graph on the client side myself.

Because there is a foreign key relationship in the database, I’m 100% certain that Single will always return a result. First() gave me the same problem too.

EDIT: The stack trace is for the First() method which I tried after the Single() method. I’m checking out the source code now, will report my findings.

  • 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-28T07:20:52+00:00Added an answer on May 28, 2026 at 7:20 am

    This would happen if the sequence is empty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have client application that uses WCF service to insert some data to backend
We have an application that uses the window message queue to pass data from
I have an application that uses the bluetooth to receive some data (bytes) from
I have an application that uses Entity Framework to access the data, and throughout
I have an application that uses pictures, audio and some text from .txt... The
We have an application that uses Lucene.NET within a windows service to reindex our
I have application that uses direct data access to it's Database. I have nothing
I have an application that uses the APNS Feedback Service to detect when a
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have an application that uses the accelerometer. Sometimes, the application will launch without

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.