10

So I found this wonderful library called WatiN - and I've downloaded the latest version - v2.1. I've opened a Console Applications (obviously C#) and wrote my most simplest program:

using WatiN.Core;
...
FireFox browser = new FireFox(@"..");
browser.Button("Send").Click();
browser.Dispose();

It's nothing much. I obviously added a reference to my project by right-clicking the project > Add Reference > browsed to C:\...\WatiN\bin\net40, chose WatiN.Core.dll (like the Readme said) The VS was auto completing my typing - and he offered me alternatives (you know - when you type con and he shows that lil' window and showing you Console etc) - like he should, because I've added the reference. Then I hit compile - and suddenly - VS turns blind and he can't detect the DLL I referenced. The DLL still shows up in the References folder in my project - but VS whines that it doesn't. He says: The type or namespace name 'WatiN' does not exist in the namespace 'WatiN' (are you missing an assembly reference?) Although he did not show those errors before compile - and marked Firefox in green (because its a class). Can anyone help me with this? Maybe well me whats wrong ? Another thing - when double clicking the DLL in the reference (aka Object Browser) it shows me it and everything's OK - but after I try to compile - it magically disappears.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Mark Segal
  • 5,427
  • 4
  • 31
  • 69
  • Are you missing any other reference required by your external assembly? – Rubens Farias Jul 18 '11 at 23:50
  • The readme clearly states what I need - and besides, the examples only included that DLL - nothing further (and the compiler great) – Mark Segal Jul 18 '11 at 23:52
  • Another thing - when double clicking the DLL in the reference (aka Object Browser) it shows me it and everything's OK - but after I try to compile - it magically disappears. – Mark Segal Jul 18 '11 at 23:55
  • Tried to restart VS, or to recreate your project? – Rubens Farias Jul 18 '11 at 23:57
  • 3
    Sometimes I've gotten such errors when I had the wrong framework version target for my project, such as 4.0 Client Profile, when I needed the full framework. – Merlyn Morgan-Graham Jul 18 '11 at 23:58
  • you just have one external assembly copy? I mean, maybe you could to have two different versions... just ideas... – Rubens Farias Jul 19 '11 at 00:00
  • @Marlyn Morgan-Grahan Woah - Microsoft always surprise me. That fixed the problem. Thank you – Mark Segal Jul 19 '11 at 00:01
  • possible duplicate of [C# Visual Studio 2010 suddenly can't see namespace?](http://stackoverflow.com/questions/4880685/c-visual-studio-2010-suddenly-cant-see-namespace) – Hans Passant Jul 19 '11 at 00:27

1 Answers1

33

In your project settings, change your Target Framework from ".NET Framework 4 Client Profile" to ".NET Framework 4". That did the trick for me.

  • thanks a lot. I spent a long time trying to find out what went wrong, because my windows service project wasn't building even after adding references to class library project. – RKP Feb 28 '12 at 11:47
  • for my case, I had to edit the project (by unloading the project and editing the csproj file) to change the target framework to v4.0. Thanks for the answer. – AceMark Aug 20 '13 at 12:56
  • 2
    THANK YOU! D'oh! A mismatched .NET framework answer in a slightly different context has given me the majority of my reputation. They really ought to make it more obvious!!! – CindyH Sep 15 '16 at 22:06