The type or namespace name 'Net' could not be found

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Al Cadalzo

    The type or namespace name 'Net' could not be found

    I get the compile error:
    "The type or namespace name 'Net' could not be found"
    on this line of code:

    Net.HttpWebResp onse resp = null;

    Here are my using directives:
    using System;
    using System.Data;
    using System.Data.Sql Client;
    using System.IO;

    If I say 'System.Net.Htt pWebResponse' then the error goes away.

    I have a similar problem when I declare a SqlConnection

    If I say SqlClient.SqlCo nnection I get the error, but If I say just
    'SqlConnection' then it's OK.
    It seems as though the 'using System' directive and the 'using System.Data'
    directive are being ignored.

    I assembly references to System, System.Data and System.XML.

    I don't have any problem with the 'using System.IO;' directive.

    Any ideas?

    Thanks,
    Al


  • bB

    #2
    Re: The type or namespace name 'Net' could not be found

    Add the following directive:

    using System.Net;

    Tim

    "Al Cadalzo" <cadalzo@hotmai l.com> wrote in message
    news:#odMhGOlDH A.2160@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I get the compile error:
    > "The type or namespace name 'Net' could not be found"
    > on this line of code:
    >
    > Net.HttpWebResp onse resp = null;
    >
    > Here are my using directives:
    > using System;
    > using System.Data;
    > using System.Data.Sql Client;
    > using System.IO;
    >
    > If I say 'System.Net.Htt pWebResponse' then the error goes away.
    >
    > I have a similar problem when I declare a SqlConnection
    >
    > If I say SqlClient.SqlCo nnection I get the error, but If I say just
    > 'SqlConnection' then it's OK.
    > It seems as though the 'using System' directive and the 'using[/color]
    System.Data'[color=blue]
    > directive are being ignored.
    >
    > I assembly references to System, System.Data and System.XML.
    >
    > I don't have any problem with the 'using System.IO;' directive.
    >
    > Any ideas?
    >
    > Thanks,
    > Al
    >
    >[/color]


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: The type or namespace name 'Net' could not be found

      Al Cadalzo <cadalzo@hotmai l.com> wrote:[color=blue]
      > I get the compile error:
      > "The type or namespace name 'Net' could not be found"
      > on this line of code:
      >
      > Net.HttpWebResp onse resp = null;[/color]

      Yes. That's because the "using" statement doesn't mean you can use
      partial *namespaces*, it just means you can use unqualified type names.

      Just include:

      using System.Net;

      and then just use

      HttpWebResponse resp = null;

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Al Cadalzo

        #4
        Re: The type or namespace name 'Net' could not be found

        Thanks Tim.
        I am used to the way you can use partial namespace in VB.NET.

        Al

        "bB" <tim@aterminal. free-serve.co.uk.don tspamme> wrote in message
        news:OhITHLOlDH A.1764@tk2msftn gp13.phx.gbl...[color=blue]
        > Add the following directive:
        >
        > using System.Net;
        >
        > Tim
        >
        > "Al Cadalzo" <cadalzo@hotmai l.com> wrote in message
        > news:#odMhGOlDH A.2160@TK2MSFTN GP10.phx.gbl...[color=green]
        > > I get the compile error:
        > > "The type or namespace name 'Net' could not be found"
        > > on this line of code:
        > >
        > > Net.HttpWebResp onse resp = null;
        > >
        > > Here are my using directives:
        > > using System;
        > > using System.Data;
        > > using System.Data.Sql Client;
        > > using System.IO;
        > >
        > > If I say 'System.Net.Htt pWebResponse' then the error goes away.
        > >
        > > I have a similar problem when I declare a SqlConnection
        > >
        > > If I say SqlClient.SqlCo nnection I get the error, but If I say just
        > > 'SqlConnection' then it's OK.
        > > It seems as though the 'using System' directive and the 'using[/color]
        > System.Data'[color=green]
        > > directive are being ignored.
        > >
        > > I assembly references to System, System.Data and System.XML.
        > >
        > > I don't have any problem with the 'using System.IO;' directive.
        > >
        > > Any ideas?
        > >
        > > Thanks,
        > > Al
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Al Cadalzo

          #5
          Re: The type or namespace name 'Net' could not be found

          Jon,

          Thanks alot. I guess it works a bit differently than the imports directive
          I'm used to in VB.Net.

          Al


          "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
          news:MPG.19fa50 db525a94de9898c 8@msnews.micros oft.com...[color=blue]
          > Al Cadalzo <cadalzo@hotmai l.com> wrote:[color=green]
          > > I get the compile error:
          > > "The type or namespace name 'Net' could not be found"
          > > on this line of code:
          > >
          > > Net.HttpWebResp onse resp = null;[/color]
          >
          > Yes. That's because the "using" statement doesn't mean you can use
          > partial *namespaces*, it just means you can use unqualified type names.
          >
          > Just include:
          >
          > using System.Net;
          >
          > and then just use
          >
          > HttpWebResponse resp = null;
          >
          > --
          > Jon Skeet - <skeet@pobox.co m>
          > http://www.pobox.com/~skeet
          > If replying to the group, please do not mail me too[/color]


          Comment

          Working...