Ok, I got a strange one here and I want to know if any of you have ever run accross anything like it.
So I've got this web app that loads up a bunch of dll's through reflection. Basically it looks for Types that are derived from certain abstract types and adds them to the list of things it can make.
Here's the weird part.
While developing there is never a problem. When installing it, there is never a problem to start with. Then, at a seemingly random time, the application breaks while trying to find all the types.
I've had 2 sites sitting side by side and one worked while the other did not, and they were configured exactly(and I mean exactly) the same.
IISRESET's never helped, but this did:
I simply moved all the dll's out of the bin directory then moved them back. That's right I just moved them out of the bin directory then put them right back where they came from and everything worked fine.
Any ideas?
Got some more info
When the site is working I notice this behavior: After IISRESET it still works, but recycling the app pool will cause it to break.
When the site is broken: Neiter IISRESET nor recycling the app pool fixes it, but moving a single dll out then back in fixes it.
Even More Info
So it turns out that IsAssignableFrom
is not returning the correct value. I would not have believed it to be true, but I had my logger log the result and the 2 types, and it definitely returned the wrong value. The crazy thing is that the same dll will return different values at different times when comparing the same 2 types.
Yet More Info
The particular class that IsAssignableFrom
fails on in located in a file with other classes. If I move the class to its own file, then everything works fine. However, if it is in the same file as other classes(even if it is in its own namespace
block) then the Type
reference is all wrong. The Type
reference will have the correct name and methods, but it has trouble finding the correct constructor.