locked
missing a using directive or an assembly reference RRS feed

  • Question

  • OK, let's get this out of the way - I'm new to C# programming and the .Net Framework and Silverlight.  However, I've done a lot of programming in my day.

    I have a text file on a server.  All I want to do is download it to my SL app and put the file contents in a text box.  Should be simple.  I've searched around and found something about using a Downloader object.

    Downloader d = new Downloader(); 

    gives me the error "missing a using directive or an assembly reference".  I look for it in the SDK doc to try to figure it out and it's not listed there.  I then read something else that says to use BrowserHttpWebRequest.

    BrowserHttpWebRequest br = new BrowserHttpWebRequest();

    gives me the same error "missing a using directive or an assembly reference".  I look for it in the SDK doc to try to figure it out and it's not listed there.

    I then crack open my new Introducing Microsoft Silverlight 2 book (Laurence Moroney) and on page 235 recommends using the WebClient class.  This class I CAN find in the SDK.  The SDK doc says the namespace is System.Net.  So I add this to my code:

    using System.Net;

    WebClient wc = new WebClient();

    I get the same error "missing a using directive or an assembly reference".  The SDK doc also says it's in the System Assembly (in System.dll).  So I go to my VS project, right click it and do Add Reference and dbl-click on the System component.  I rebuild and get the same error.

    I know this must be simple, but I'm stuck.

    Thursday, July 3, 2008 10:45 AM

Answers

  • All is well now.  I'm not sure why.  I fiddled with VS and expanded the References tab in the Solution Explorer for my project.  System.Net was not there, so I added it by right clicking on References.  The strange thing is that earlier I had right clicked on my project name and choosen "Add Reference" and added System.Net.  For some reason it didn't get added to the References tab.  Bug perhaps?  I would assume doing Add Reference from either the project name or by clicing on the References is the same?

    Thursday, July 3, 2008 11:42 AM