Are you trying to use Templated User Controls and getting missing using directive or assembly errors?
Thursday, September 18, 2008 10:34 PM
In my ODNC MCTS Study group session this week, we did Web User Controls and more specifically Templated User Controls. At the presentation this week, DL gave an awesome presentation which made me go revsit the Templated User Controls. After TWO FULL NIGHTS of none functioning code, I was starting to think that was a bad decision! I kept getting these error messages!
See the little teeny-tiny red squiggles under ShipperContainer and the missing using directive or assembly reference message? That message has been staring me in the face all night! :< The crux of all this is VS is unable to find the ShipperContainer class which is dutifully created in the App_Code directory. Below is a screen cap of opening the website in a Solution, notice the icon on the App_Code directory (grey coloured folder).
Now, let's open the same website but as a website.
You will see the App_Code icon now change (similar folder to above but this time with a doc-like image superimposed on it).
BINGO! Hit F6 and everything compiles JUST fine! Turns out, it's got NOTHING to do with the code but everything to do with the surrounding solution/project!
Yes, that's right, in trying to keep things clean and neat with my code, I create and use Solutions with individual Projects for different aspects in the book we're learning. Long story short, if you're getting this FRUSTRATION, uh, error, you need to open a Website, not a Solution/Project. Once you do that (I hope! :>) your compile errors about missing using directives will go away.
Oh, and one closing note, VS will try to save a Solution file for you as soon as you hit the F6 to compile. You should be good to go with opening up that Solution file the next time. Not quite sure why that is though?! Any commenters?
References: I want to thank Peppi and KDavie for asking and answering this question just a week and a half ago!