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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:58:26+00:00 2026-05-10T21:58:26+00:00

Using Visual Studio 2008 / C# / VS Unit Testing. I have a very

  • 0

Using Visual Studio 2008 / C# / VS Unit Testing.

I have a very straightforward extension method, that will tell me if an object is of a specific type:

public static bool IsTypeOf<T, O>(this T item, O other) {     if (!(item.GetType() is O))         return false;     else         return true; } 

It would be called like:

Hashtable myHash = new Hashtable(); bool out = myHash.IsTypeOf(typeof(Hashtable)); 

The method works just fine when I run the code in debug mode or if I debug my unit tests. However, the minute I just run all the unit tests in context, I mysteriously get a MissingMethodException for this method. Strangely, another extension method in the same class has no problems.

I am leaning towards the problem being something other than the extension method itself. I have tried deleting temporary files, closing/reopening/clean/rebuilding the solution, etc. So far nothing has worked.

Has anyone encountered this anywhere?

Edit: This is a simplified example of the code. Basically, it is the smallest reproducible example that I was able to create without the baggage of the surrounding code. This individual method also throws the MissingMethodException in isolation when put into a unit test, like above. The code in question does not complete the task at hand, like Jon has mentioned, it is more the source of the exception that I am currently concerned with.

Solution: I tried many different things, agreeing with Marc’s line of thinking about it being a reference issue. Removing the references, cleaning/rebuilding, restarting Visual Studio did not work. Ultimately, I ended up searching my hard drive for the compiled DLL and removed it from everywhere that did not make sense. Once removing all instances, except the ones in the TestResults folder, I was able to rebuild and rerun the unit tests successfully.

As to the content of the method, it was in unit testing that I discovered the issue and was never able to get the concept working. Since O is a RunTimeType, I do not seem to have much access to it, and had tried to use IsAssignableFrom() to get the function returning correctly. At this time, this function has been removed from my validation methods to be revisited at another time. However, prior to removing this, I was still getting the original issue that started this post with numerous other methods.

Post-solution: The actual method was not as complex as I was making it out to be. Here is the actual working method:

public static void IsTypeOf<T>(this T item, Type type) {     if (!(type.IsAssignableFrom(item.GetType())))         throw new ArgumentException('Invalid object type'); } 

and the unit test to verify it:

[TestMethod] public void IsTypeOfTest() {     Hashtable myTable = new Hashtable();     myTable.IsTypeOf(typeof(Hashtable));      try     {         myTable.IsTypeOf(typeof(System.String));         Assert.Fail('Type comparison should fail.');     }     catch (ArgumentException)     { } } 
  • 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. 2026-05-10T21:58:27+00:00Added an answer on May 10, 2026 at 9:58 pm

    Usually, a MissingMethodException means that you are loading a different version of the dll to the one you referenced during build, and the actual dll you are loading (at run-time) doesn’t have the method the compiler found (at compile-time).

    Check that you haven’t somehow got various versions of the dll referenced by different projects. It could be that when you run it in debug mode, some other code makes the correct dll load first, but when running in-context, this other code doesn’t run – so the incorrect version loads instead.

    This would apply doubly if the failing method was added recently, so might not be in the older version referenced.

    If you are using full assembly versioning, you might be able to watch the debug output to see exactly which assembly loads.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You're looking at 12 bytes per structure, so passing it… May 11, 2026 at 11:40 am
  • added an answer Try this: vector<Type>::iterator nth = v.begin() + index; May 11, 2026 at 11:40 am
  • added an answer string clause = 'PAGENUMBER'; string operand = '!='; string value=… May 11, 2026 at 11:40 am

Related Questions

Using Visual Studio 2008 / C# / VS Unit Testing. I have a very
Applications I am using: Visual Studio 2008 (C#/ASP.NET) Visual Source Safe 8.0 IIS 5.1
I'm using Visual Studio 2008 and I'm used to C# where when Intellisense pops
I'm using Visual Studio 2008 and the built-in installation tools for a C# client
I'm making a winform in C# using Visual Studio 2008. Currently, I have a
I'm porting a Java library to C#. I'm using Visual Studio 2008, so I
Using C# in Visual Studio 2008 and stepping through a function in the debugger
I've got a Web Service written using C# in Visual Studio 2008 (I've also
I'm writing a GUI in C#, Visual Studio 2008, using the Designer and WinForms.
Using Visual Studio 2008 Team Edition, is it possible to assign a shortcut key

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.