UPDATE:
I ended up solving this in a way I did not expect - it apparently was not the namespace/typename collision I thought it was (to my surprise when I re-did it and it failed the exact same way). I think maybe this is minor VS bug - here's what happened:
--> The error path
- I added a Winforms project
- I added a reference to Lib1
- Lib1 appeared as an added reference
- (I revise my estimate of exactly when VS gets "confused") The next time I compile, things get broken and it's as if I never added the reference to Lib1.
--> Surprising way I ended up resolving the issue:
- I was taking random shots because I was confused and I decided to add the library a (slightly) different way.
- Instead of right clicking the References node in the Solution Explorer and choosing Lib1 from the "solutions" tab, I chose it from the "Recent" tab.
- When I added it, to my surprise, VS complained that it could not add the library
- The reason was my Library was set to .NET 4 and my Winforms app defaulted to Client profile.
--> the issue was resolved when I switched my winforms app to .NET 4
Background/Motivation:
I'm a lone developer - which is why when I have strangnesses like this one, I sometimes spend 20 minutes and if I can't figure it out I completely work around it. Sometimes these problems recur, and I spend another 20 minutes, and become annoyed with the workaround a second time, which finally makes me really want to figure it out. This is the case now.
Description of the Problem:
I'm coding along, in this case, I was prototyping an ASP.NET website with VS10.
- new project, ASP.NET website: Web1 (creates solution)
- add Project, C# library, Lib1 (adds to solution)
- Lib1: add Model.cs, View.cs, Presenter.cs, ...etc
- Web1: add a DataList to Default.aspx, bind data via Lib1
- Test it it works
---> Now I want to see my Lib1 work for a winforms project, basically proving to myself I can write Library code that doesn't care about the UI
- add Project, WinformsApp1 (adds to solution)
- add a DataGridView to Form1, bind data via Lib1
Then the wierdest thing happend (at least to me): At first, adding a reference to Lib1 and implementing the IView interface on Form1 works fine, but as soon as VS auto populates th开发者_如何学Pythone stubs for IView, everything goes to a state as if I didn't add the reference to Lib1. That is, the compiler tells me it doesn't know the definition of IView, and politely reminds me that I might have forgotten to add a reference, but the kicker is that it's talking about the code that it just generated and would not have been able to without that reference.
NOTE: If nobody knows just what this is and I'm wrong that this is a symptom of lone developer syndrome, I'll work up the example again and post the code (I just zapped it).
It sounds like you have a method in your interface that has the same name as the namespace, so when you populated the interface the compiler could no longer differentiate between the namespace and the method.
精彩评论