[Mono-list] The type or namespace name `WebClient' could not be found.

Andy Hume andyhume32 at yahoo.co.uk
Wed Aug 27 07:07:21 EDT 2008


Response inline.


Chris F wrote:
> 
> I'm trying to compile a C# app on Ubuntu with Mono 1.9.1
> Mono was compiled with only --prefix.
> 
> The code is:
> 
> using System;
> using System.Web;
> using System.IO;
> using System.Xml;
> .
> .
> .
> 
> WebClient imgClient = new WebClient();
> 
> 
> Now when I compile:
> Target CoreCompile:
>                 Tool /opt/mono-1.9.1/bin/gmcs execution started with
> arguments: /noconfig /debug:full /debug+ /optimize-
> /out:bin/Debug/ECommerceBridge.Plugins.dll PluginBase.cs
> Properties/AssemblyInfo.cs UserFilesManager.cs CredentialsManager.cs
> CartManager.cs /target:library /unsafe- /define:DEBUG;TRACE
> /reference:/opt/mono-1.9.1/lib/mono/gac/log4net/1.2.9.0__b32731d11ce58905/log4net.dll
> /reference:/d0/ecommercebridge/Bin/ECommerceBridge.API.dll
> /reference:/d0/ecommercebridge/Bin/Modules.Model.dll
> /reference:/d0/ecommercebridge/Bin/MySql.Data.dll
> /reference:/opt/mono-1.9.1/lib/mono/gac/System/2.1.0.0__b77a5c561934e089/System.dll
> /reference:/opt/mono-1.9.1/lib/mono/gac/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
> /reference:/opt/mono-1.9.1/lib/mono/gac/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
> /reference:/opt/mono-1.9.1/lib/mono/gac/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
> /reference:/opt/mono-1.9.1/lib/mono/gac/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
> /warn:4
> UserFilesManager.cs(51,9):   error CS0246:  The type or namespace name
> `WebClient' could not be found. Are you missing a using directive or an
> assembly reference?
> UserFilesManager.cs(90,17):   error CS0246:  The type or namespace name
> `WebClient' could not be found. Are you missing a using directive or an
> assembly reference?
> 

There's something wrong there. 
"...gac/System/2.1.0.0__b77a5c561934e089/System.dll" is a reference to the
Silverlight version of System.dll.  It should reference version 2.0.  I
don't know why that has happened.  Are you compiling in MonoDevelop?  Maybe
someone else can explain why that might happen.

Or are you using xbuild?


Chris F wrote:
> 
> From what I gather System.Net is included in System.
> Also I've tried adding: using System.net that doesn't work
> Tried prepending WebClient with System.Net that doesn't work
> 

It is System.Net.WebClient, so the latter should work.  But the casing is
wrong in the former.

Works for me anyway:

linux at linux:~> cat wc.cs 
using System;
using System.Net;

class Foo
{
    static void Main()
    {
        WebClient cli = new WebClient();
        Console.WriteLine();
    }
}
linux at linux:~> gmcs wc.cs 
wc.cs(8,19): warning CS0219: The variable `cli' is assigned but its value is
never used
Compilation succeeded - 1 warning(s)
linux at linux:~> 



Chris F wrote:
> 
> I've added it as a direct reference in an ItemGroup in the csproj file..
>     <Reference Include="System.Net" />
> 
> It doesn't like that at all.
> 
> How can I get this to compile?
> I'm at my wits end.
> 
> Thanks
> 
> Chris
> 
> 

-- 
View this message in context: http://www.nabble.com/The-type-or-namespace-name-%60WebClient%27-could-not-be-found.-tp19171520p19178792.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list