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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:21:02+00:00 2026-05-11T08:21:02+00:00

I have a really weird issue that I can’t figure out with comparing objects

  • 0

I have a really weird issue that I can’t figure out with comparing objects on IIS 7. We are in the process of deploying our old IIS 6 based ASP.NET application on IIS 7, however we have this equality comparison issue that we can’t seem to figure out.

Let me start out by saying that I have the same assemblies and code running both on IIS 6 and IIS 7, however the comparison of the objects is differing with the same code both on IIS 6 and IIS 7. Here is an example of what my object looks like:

class Country : EntityBase {     public int CountryID { get; set; }     public string Name { get; set; }      public override bool Equals(object obj) {         if (obj == null || !(obj is Country))             return false;          Country c = (Country)obj;         return CountryID == c.CountryID;     }      public override int GetHashCode() {         return CountryID.GetHashCode();     } } 

I have the following code in an ASPX page both on IIS 6 and IIS 7:

<% foreach(var country in proposalCountries) { %> <%= country.Country.CountryID %> <%= country.Country.CountryID.GetHashCode() %> <%= country.Country.GetHashCode() %>  <%= proposalCountryServices.Count(c => c.Country == country.Country) %> <%= proposalCountryServices.Count(c => (c.Country != null && country.Country != null) && c.Country.Equals(country.Country)) %>) <%= proposalCountryServices.Count(c => Object.Equals(c.Country, country.Country)) %> <% } %> 

Here are my results:

IIS 6:

100 <-- CountryID 100 <-- CountryID Hash Code 100 <-- Country Hash Code  1 <-- Something Found 1 <-- Something Found 1 <-- Something Found 

IIS 7:

100 <-- CountryID 100 <-- CountryID Hash Code 100 <-- Country Hash Code  0 <-- Nothing Found 1 <-- Something Found 1 <-- Something Found 

Is there a difference between .NET 3.5 SP1 on Windows 2003 vs Windows 2008? I am really at a loss of what the problem could be. Has anybody experienced a similar issue?

Update 1:

To answer Jon’s question. The two collections are loaded using NHibernate. But I feel I should reiterate that both IIS 6 and IIS 7 are using the exact same build of the application, so unless NHibernate or DynamicProxy2 is changing how things are loaded based on Windows 2003 or Windows 2007, which I haven’t been able to find anything about on Google, I don’t know what to make of it.

This is also a system wide issue of whenever I am comparing two of my entity objects. So it could have something to do with the DynamicProxy2 wrapper, but both objects are Country objects and given the overrides I have created everything should work the same in IIS 6 and IIS 7.

Update 2:

This appears to be a DynamicProxy2 or NHibernate issue. Because I tried the following code:

<%     var c1 = new ICost.Business.Entities.Country {         CountryID = 100     };     var c2 = new ICost.Business.Entities.Country {         CountryID = 100     }; %> <%= c1.CountryID == c2.CountryID %> <%= c1.GetHashCode() == c2.GetHashCode() %> <%= c1.Equals(c2) %> <%= Object.Equals(c1, c2) %> <%= c1 == c2 %> 

And for both IIS 6 and IIS 7 the result was, true, true, true, true, false. See my answer below for what I did to solve this.

Update 3:

This also might have had something to do with it: Looks like you forgot to register the http module with Windsor Castle with IIS7

  • 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-11T08:21:02+00:00Added an answer on May 11, 2026 at 8:21 am

    This is the solution that worked for me:

    public static bool operator ==(BaseEntity a, BaseEntity b) {     return Object.Equals(a, b); }  public static bool operator !=(BaseEntity a, BaseEntity b) {     return !Object.Equals(a, b); } 

    Apparently NHibernate or DynamicProxy was doing some kind of magic under Windows 2003 to get the ‘==’ operator to work with out the operator being overloaded.

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • 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
  • Editorial Team
    Editorial Team added an answer First of all, to send the screenshot, you can use… May 11, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer I figured it out: window.nativeWindow.x = (Screen.mainScreen.bounds.width - window.width)/2; window.nativeWindow.y… May 11, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer Ok I solved my problem. It was not Message.WriteMessage that… May 11, 2026 at 11:41 pm

Related Questions

I have a really weird issue that I can't figure out with comparing objects
I have a problem with a simple included file. The file being included is
I'm trying to do a batch upload of photos in my iPhone application. I
I have just ported several of our home-made Outlook COM-addins from Delphi 2007 to
Okay, this one is REALLY weird. I'm using .net for my backend and Flex

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.