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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:54:34+00:00 2026-06-12T02:54:34+00:00

I am using Visual studio 2010 with c# and SQL Management studio. I am

  • 0

I am using Visual studio 2010 with c# and SQL Management studio.

I am working on the mailbox feature.

I written a method for if a user click for reply button the content for reply is like this..

private string adjustContentForReply(List<Guid> sender)
    {
        string content = string.Empty;
        messageID = (Guid)Session["messageID"];

        //haal de ontvangers uit de database van het bericht
        List<Guid> receivers = m.bussinesCollection.BussinesMessageReceiver.GetReceivers(messageID);

        //pas de inhoud van het bericht aan met de details van het vorige bericht
        content = "<br /><br />----------------------------------------<br />";
        content += "Ontvangen op: " + m.bussinesCollection.BussinesMessageReceiver.GetMessageReceiver(messageID, boxOwner).DateReceived.ToString() + "<br />";
        content += "Onderwerp: " + m.bussinesCollection.BussinesMessage.GetMessageSubject(messageID) + "<br />";
        content += "Van: " + m.bussinesCollection.BussinesPerson.GetFullName(sender[0]) + "<br />";
        content += "Aan: ";

        //Voeg één of meerdere ontvangers toe aan details
        foreach (Guid rec in receivers)
        {
            content += m.bussinesCollection.BussinesPerson.GetFullName(rec);
            if (receivers.Count() > 1)
                content += "; ";
        }
        content += "<br />";
        content += "----------------------------------------<br /><br />";

        //voeg de inhoud van het vorige bericht aan de content
        content += m.bussinesCollection.BussinesMessage.GetMessageContent(messageID);

        return content;
    }

It is giving me error in line

content += "Ontvangen op: " + m.bussinesCollection.BussinesMessageReceiver.GetMessageReceiver(messageID, boxOwner).DateReceived.ToString() + "<br />";

the erroe is

Object reference not set to an instance of an object.

the GetMessageReceiver() is like this

public MessageReceiver GetMessageReceiver(Guid msgId, Guid personId)
        {
            var message = from msg in Db.MessageReceivers
                          where msg.MessageID.Equals(msgId) && msg.ReceiverID.Equals(personId)
                          select msg;

          return  message.Count().Equals(1) ? message.First() : null;
        }

when I debugged it and taken the messageId and BoxOwnerId and fire a query in Database,it shows two rows for the given combination.

can any one help me?

Hey the problem is solved from there and now i can create a message for reply.
But on clicking on the send button page the same error now thrown there.

  • 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-06-12T02:54:35+00:00Added an answer on June 12, 2026 at 2:54 am

    You get the error because you’re not checking the return value of GetMessageReceiver(). You either need to make sure that GetMessageReceiver cannot return null, or you need to check the return value before using any functions on it

    MessageReceiver receiver = m.bussinesCollection.BussinesMessageReceiver.GetMessageReceiver(messageID, boxOwner);
    if (receiver == null)
        // handle error
        return;
    
    content += "Ontvangen op: " + receiver.DateReceived.ToString() + "<br />";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; What I'm ultimately trying to do is update a sql
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; Kinda new at C# here.. I got the first row
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studios.R2.Express; What I'm trying to do, is get a button to
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; N00b here, I've got the gridview to look the way
I'm using Visual Web Developer 2010 Express and SQL Server 2008 R2 Management Studio
I am using Microsoft Visual Studio Professional 2010. (Also SQL Management Studio for my
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; using Northwind; N00b here, Trying to customize a asp.net gridview
Using Visual Studio 2010 and SQL management Studio, I have created a page by
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; N00b here, I have a GridView, but I want to
I have created SQL Server 2008 Database project using visual studio 2010. after build

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.