Tuesday, March 30, 2010

x does not contain a definition for y

I just ran across this problem... again... and because I didn't note the solution last time I had to figure it out again. It's so simple - but so hard to remember. Let's hope that next time I hit this I'll at least remember that I blogged about it. Here we go.

I'm building a web site, and it makes use of some DLLs that come from some C# libraries I've built. Over the course of time, I've added some functions to the libraries that I use in my website. And the website picks up the new functions and everything is great.

Then one day I come along and try to build the website in Visual Studio, but it gives me an error because it says that one of the newer functions in my library is missing. Here's the error:
className does not contain a definition for functionName
Hmm. I check the other project (which lives in the same solution), and the function is there. So I go to my web control, which is generating the error, I right click on the function name, and click 'Go to Definition', and sure enough, it jumps right to the function.

After a couple of hours of removing pieces and parts from different projects and trying to narrow things down, all without any avail, a thought finally hits my brain. The GAC!

Sure enough, an older version of my library somehow ended up in the GAC. I removed it from the GAC, then everything built just fine.

FYI, to remove a library from the GAC, browse in windows explorer to c:\windows\assembly, right click on the dll you want to remove, and click 'uninstall.'