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

  • Home
  • SEARCH
  • 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 6119819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:35:49+00:00 2026-05-23T15:35:49+00:00

I tried to have Visual Studio 2010 create unit tests for the following class,

  • 0

I tried to have Visual Studio 2010 create unit tests for the following class, however, the following error was thrown. I researched and found that this is caused by a reference not being set before it is used, however, I do not see where this problem exists in my code.

[Serializable]
class PrintUser : IEquatable<PrintUser>
{
    public string Username { get; private set; }
    public int PageLimit { get; set; }
    public bool LimitEnforced { get; set; }

    public PrintUser(string userName)
    {
        this.Username = userName;
    }

    bool IEquatable<PrintUser>.Equals(PrintUser other)
    {
        return this.Username == other.Username;
    }
}

While trying to generate your tests, the following errors occurred:
Object reference not set to an instance of an object.

UPDATE: I fixed the problem of not checking for null, however that did not solve the problem. The error occurs when trying to generate the test code. There is also another strange error that just started occurring on another class. I wrote the class, and then right clicked on the equals method and chose to create a unit test for just that method. Then, the error occurred and there was not any test code generated.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets(14,5): error : Signature of the body and declaration in a method implementation do not match. Type: ‘PrintMonitorComponents.ADUserGroup_Accessor’. Assembly: ‘PrintMonitorComponents_Accessor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’.

UPDATE: The PrintUser class (shown above) is also throwing a similar error which is listed below. I have updated my code to check for null in the equals method.

Signature of the body and declaration in a method implementation do not match. Type: ‘PrintMonitorComponents.PrintUser_Accessor’. Assembly: ‘PrintMonitorComponents_Accessor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’. PrintMonitorComponentsTest

  • 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-23T15:35:50+00:00Added an answer on May 23, 2026 at 3:35 pm

    I have no idea why, but the error stopped occurring after I changed the interface implementation from explicit to implicit. Also, after this change, Visual Studio 2010 is able to generate unit tests/code normally.

    Here is the error that I was receiving again:

    Signature of the body and declaration in a method implementation do not match. Type: ‘PrintMonitorComponents.PrintUser_Accessor’. Assembly: ‘PrintMonitorComponents_Accessor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’. PrintMonitorComponentsTest

    Here is the new code:

    [Serializable]
    class PrintUser : IEquatable<PrintUser>
    {
        public string Username { get; private set; }
        public int PageLimit { get; set; }
        public bool LimitEnforced { get; set; }
    
        public PrintUser(string userName)
        {
            this.Username = userName;
        }
    
        public bool Equals(PrintUser other)
        {
            if (other == null)
            {
                return false;
            }
            else
            {
                return this.Username == other.Username;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've create the following class in Visual Studio 2010: public class Bat : Form1
I am using visual studio 2010 and tried to create a class library which
I have tried creating several web parts using Visual Studio 2010 using available guides
I have installed Visual Studio 2008 (also tried with 2010 beta) and cannot see
I have Visual Studio 2008 Express SP1 installed on my machine. I tried to
I've got a winform app in visual studio 2010. My app does the following
I have virtual machine that has windows 7 + visual studio 2010 setup, and
As part of our Visual Studio 2010 (primarly C# 4.0) development standards, we have
I just installed visual studio 2010 but when i create a new project Framework
I have a C# (Visual Studio 2010) project that opens Internet Explorer 8 like

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.