Question about namespaces and classes...

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

    #1

    Question about namespaces and classes...

    All,

    I have a simple C# window app under MyApp namespace it has a class Form1.
    I've added another class .cs file.
    Now this class I want to share with many projects, so I figured I'd change
    this class.cs file from

    namespace MyApp
    Class MyClass

    to:
    namespace MyCompanyName
    namespace LogicalGroup
    class MyNewClassName

    In the form class I try
    MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction () and it
    complains that MyCompanyName namespace could not be found? I tried a using
    MyCompanyName and the namespaces I just created do not show up in
    intellisense</> popups.

    Obviously I need to do this a bit differently to get it to work, but I don't
    want a separate assembly, dll or exe that will need to be installed or
    copied in order to do this. What am I missing or is there a different route
    I need to take?


    Regards,
    Erin.


  • EMonaco

    #2
    Re: Question about namespaces and classes...

    Joe,

    Done that. Comment out the
    MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunc() and it compile
    fine.
    Remove the // and compile and viola, same error as before.... *sigh*


    Erin.

    "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
    news:%23FubPJDb DHA.2032@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > What you're trying to do looks okay to me. I've had this type of problem
    > when there was some other type of error in the file, which causes
    > intellisense not to show on the line I'm working with. Maybe you could
    > remove the reference, get a good compile, and try again.
    >
    > Joe
    > --
    > http://www.csharp-station.com
    >
    > "EMonaco" <erinmonaco@nos pam.net> wrote in message
    > news:ONO7q3CbDH A.384@TK2MSFTNG P12.phx.gbl...[color=green]
    > > All,
    > >
    > > I have a simple C# window app under MyApp namespace it has a class[/color]
    > Form1.[color=green]
    > > I've added another class .cs file.
    > > Now this class I want to share with many projects, so I figured I'd[/color][/color]
    change[color=blue][color=green]
    > > this class.cs file from
    > >
    > > namespace MyApp
    > > Class MyClass
    > >
    > > to:
    > > namespace MyCompanyName
    > > namespace LogicalGroup
    > > class MyNewClassName
    > >
    > > In the form class I try
    > > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction () and it
    > > complains that MyCompanyName namespace could not be found? I tried a[/color][/color]
    using[color=blue][color=green]
    > > MyCompanyName and the namespaces I just created do not show up in
    > > intellisense</> popups.
    > >
    > > Obviously I need to do this a bit differently to get it to work, but I[/color]
    > don't[color=green]
    > > want a separate assembly, dll or exe that will need to be installed or
    > > copied in order to do this. What am I missing or is there a different[/color]
    > route[color=green]
    > > I need to take?
    > >
    > >
    > > Regards,
    > > Erin.
    > >
    > >[/color]
    >
    >[/color]


    Comment

    • Joe Mayo

      #3
      Re: Question about namespaces and classes...

      Is the class in a separate assembly? If so, did you accidently lose your
      reference? I suppose if you press Ctrl-Space MyCompanyName doesn't appear
      in the list.

      Joe
      --
      Learn C# with step-by-step tutorials and practical examples. Start your first program, explore lists and parsing, and understand how .NET runs your code.


      "EMonaco" <erinmonaco@nos pam.net> wrote in message
      news:uPa$3MDbDH A.1740@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Joe,
      >
      > Done that. Comment out the
      > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunc() and it compile
      > fine.
      > Remove the // and compile and viola, same error as before.... *sigh*
      >
      >
      > Erin.
      >
      > "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
      > news:%23FubPJDb DHA.2032@TK2MSF TNGP10.phx.gbl. ..[color=green]
      > > What you're trying to do looks okay to me. I've had this type of[/color][/color]
      problem[color=blue][color=green]
      > > when there was some other type of error in the file, which causes
      > > intellisense not to show on the line I'm working with. Maybe you could
      > > remove the reference, get a good compile, and try again.
      > >
      > > Joe
      > > --
      > > http://www.csharp-station.com
      > >
      > > "EMonaco" <erinmonaco@nos pam.net> wrote in message
      > > news:ONO7q3CbDH A.384@TK2MSFTNG P12.phx.gbl...[color=darkred]
      > > > All,
      > > >
      > > > I have a simple C# window app under MyApp namespace it has a class[/color]
      > > Form1.[color=darkred]
      > > > I've added another class .cs file.
      > > > Now this class I want to share with many projects, so I figured I'd[/color][/color]
      > change[color=green][color=darkred]
      > > > this class.cs file from
      > > >
      > > > namespace MyApp
      > > > Class MyClass
      > > >
      > > > to:
      > > > namespace MyCompanyName
      > > > namespace LogicalGroup
      > > > class MyNewClassName
      > > >
      > > > In the form class I try
      > > > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction () and[/color][/color][/color]
      it[color=blue][color=green][color=darkred]
      > > > complains that MyCompanyName namespace could not be found? I tried a[/color][/color]
      > using[color=green][color=darkred]
      > > > MyCompanyName and the namespaces I just created do not show up in
      > > > intellisense</> popups.
      > > >
      > > > Obviously I need to do this a bit differently to get it to work, but I[/color]
      > > don't[color=darkred]
      > > > want a separate assembly, dll or exe that will need to be installed or
      > > > copied in order to do this. What am I missing or is there a different[/color]
      > > route[color=darkred]
      > > > I need to take?
      > > >
      > > >
      > > > Regards,
      > > > Erin.
      > > >
      > > >[/color]
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Jeffrey Tan[MSFT]

        #4
        Re: Question about namespaces and classes...


        Hi EMonaco,

        Have you compiled before using your customer class?
        In my sample project, it just works well.

        Jeffrey Tan
        Microsoft Online Partner Support
        Get Secure! - www.microsoft.com/security
        This posting is provided "as is" with no warranties and confers no rights.

        --------------------
        | From: "EMonaco" <erinmonaco@nos pam.net>
        | References: <ONO7q3CbDHA.38 4@TK2MSFTNGP12. phx.gbl>
        <#FubPJDbDHA.20 32@TK2MSFTNGP10 .phx.gbl>
        | Subject: Re: Question about namespaces and classes...
        | Date: Tue, 26 Aug 2003 20:33:51 -0400
        | Lines: 63
        | X-Priority: 3
        | X-MSMail-Priority: Normal
        | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
        | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
        | Message-ID: <uPa$3MDbDHA.17 40@TK2MSFTNGP10 .phx.gbl>
        | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
        | NNTP-Posting-Host: bgp01114046bgs. westln01.mi.com cast.net 68.42.93.214
        | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
        | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1796 88
        | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
        |
        | Joe,
        |
        | Done that. Comment out the
        | MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunc() and it compile
        | fine.
        | Remove the // and compile and viola, same error as before.... *sigh*
        |
        |
        | Erin.
        |
        | "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
        | news:%23FubPJDb DHA.2032@TK2MSF TNGP10.phx.gbl. ..
        | > What you're trying to do looks okay to me. I've had this type of
        problem
        | > when there was some other type of error in the file, which causes
        | > intellisense not to show on the line I'm working with. Maybe you could
        | > remove the reference, get a good compile, and try again.
        | >
        | > Joe
        | > --
        | > http://www.csharp-station.com
        | >
        | > "EMonaco" <erinmonaco@nos pam.net> wrote in message
        | > news:ONO7q3CbDH A.384@TK2MSFTNG P12.phx.gbl...
        | > > All,
        | > >
        | > > I have a simple C# window app under MyApp namespace it has a class
        | > Form1.
        | > > I've added another class .cs file.
        | > > Now this class I want to share with many projects, so I figured I'd
        | change
        | > > this class.cs file from
        | > >
        | > > namespace MyApp
        | > > Class MyClass
        | > >
        | > > to:
        | > > namespace MyCompanyName
        | > > namespace LogicalGroup
        | > > class MyNewClassName
        | > >
        | > > In the form class I try
        | > > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction () and
        it
        | > > complains that MyCompanyName namespace could not be found? I tried a
        | using
        | > > MyCompanyName and the namespaces I just created do not show up in
        | > > intellisense</> popups.
        | > >
        | > > Obviously I need to do this a bit differently to get it to work, but I
        | > don't
        | > > want a separate assembly, dll or exe that will need to be installed or
        | > > copied in order to do this. What am I missing or is there a different
        | > route
        | > > I need to take?
        | > >
        | > >
        | > > Regards,
        | > > Erin.
        | > >
        | > >
        | >
        | >
        |
        |
        |

        Comment

        • EMonaco

          #5
          Re: Question about namespaces and classes...

          Joe,

          The class is a seperate .cs file included as part of the project.
          If I switch to the Class View pane I can see both (top level) namespaces,
          and all the class, members, etc below them!
          If I do ctrl-space I *do* see DataBasementSof tware.... recompile- still
          nothing.


          So I deleted the line, ctrl-space will not bring the popup when i have an
          incomplete line such as this.rtbTextToP ass =
          I deleted the line again. Start with ctrl-space, go through the popup
          namespaces MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction (
          then put in the args that displayed, terminated it with ): and then went to
          the start and added the this.rtbTextToP ass = in front of it... recompiled
          and what do you know... it worked!

          Went back to the original- checked case and spelling and its identical, so I
          don't know what gives with that!?
          Thanks for the help though. Have to remember that ctrl-space trick. As a
          side note- I wish intellisense would always work- I've noticed if you have
          errors- (ie; forget the ; terminator have mismatched ()'s etc, that it will
          no longer show).

          Erin.


          "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
          news:%23LfEbhDb DHA.3248@tk2msf tngp13.phx.gbl. ..[color=blue]
          > Is the class in a separate assembly? If so, did you accidently lose your
          > reference? I suppose if you press Ctrl-Space MyCompanyName doesn't appear
          > in the list.
          >
          > Joe
          > --
          > http://www.csharp-station.com
          >
          > "EMonaco" <erinmonaco@nos pam.net> wrote in message
          > news:uPa$3MDbDH A.1740@TK2MSFTN GP10.phx.gbl...[color=green]
          > > Joe,
          > >
          > > Done that. Comment out the
          > > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunc() and it[/color][/color]
          compile[color=blue][color=green]
          > > fine.
          > > Remove the // and compile and viola, same error as before.... *sigh*
          > >
          > >
          > > Erin.
          > >
          > > "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
          > > news:%23FubPJDb DHA.2032@TK2MSF TNGP10.phx.gbl. ..[color=darkred]
          > > > What you're trying to do looks okay to me. I've had this type of[/color][/color]
          > problem[color=green][color=darkred]
          > > > when there was some other type of error in the file, which causes
          > > > intellisense not to show on the line I'm working with. Maybe you[/color][/color][/color]
          could[color=blue][color=green][color=darkred]
          > > > remove the reference, get a good compile, and try again.
          > > >
          > > > Joe
          > > > --
          > > > http://www.csharp-station.com
          > > >
          > > > "EMonaco" <erinmonaco@nos pam.net> wrote in message
          > > > news:ONO7q3CbDH A.384@TK2MSFTNG P12.phx.gbl...
          > > > > All,
          > > > >
          > > > > I have a simple C# window app under MyApp namespace it has a class
          > > > Form1.
          > > > > I've added another class .cs file.
          > > > > Now this class I want to share with many projects, so I figured I'd[/color]
          > > change[color=darkred]
          > > > > this class.cs file from
          > > > >
          > > > > namespace MyApp
          > > > > Class MyClass
          > > > >
          > > > > to:
          > > > > namespace MyCompanyName
          > > > > namespace LogicalGroup
          > > > > class MyNewClassName
          > > > >
          > > > > In the form class I try
          > > > > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction () and[/color][/color]
          > it[color=green][color=darkred]
          > > > > complains that MyCompanyName namespace could not be found? I tried a[/color]
          > > using[color=darkred]
          > > > > MyCompanyName and the namespaces I just created do not show up in
          > > > > intellisense</> popups.
          > > > >
          > > > > Obviously I need to do this a bit differently to get it to work, but[/color][/color][/color]
          I[color=blue][color=green][color=darkred]
          > > > don't
          > > > > want a separate assembly, dll or exe that will need to be installed[/color][/color][/color]
          or[color=blue][color=green][color=darkred]
          > > > > copied in order to do this. What am I missing or is there a[/color][/color][/color]
          different[color=blue][color=green][color=darkred]
          > > > route
          > > > > I need to take?
          > > > >
          > > > >
          > > > > Regards,
          > > > > Erin.
          > > > >
          > > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Jeffrey Tan[MSFT]

            #6
            Re: Question about namespaces and classes...


            Hi Joe,

            I am glad it worked finally.
            I recommand you do the same thing in a new project to find if the problem
            still arise.
            If it still arise, please feel free to tell me

            Best regards,
            Jeffrey Tan
            Microsoft Online Partner Support
            Get Secure! - www.microsoft.com/security
            This posting is provided "as is" with no warranties and confers no rights.

            --------------------
            | From: "EMonaco" <erinmonaco@nos pam.net>
            | References: <ONO7q3CbDHA.38 4@TK2MSFTNGP12. phx.gbl>
            <#FubPJDbDHA.20 32@TK2MSFTNGP10 .phx.gbl>
            <uPa$3MDbDHA.17 40@TK2MSFTNGP10 .phx.gbl>
            <#LfEbhDbDHA.32 48@tk2msftngp13 .phx.gbl>
            | Subject: Re: Question about namespaces and classes...
            | Date: Tue, 26 Aug 2003 22:03:02 -0400
            | Lines: 113
            | X-Priority: 3
            | X-MSMail-Priority: Normal
            | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
            | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
            | Message-ID: <uKd#p#DbDHA.22 84@TK2MSFTNGP12 .phx.gbl>
            | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
            | NNTP-Posting-Host: bgp01114046bgs. westln01.mi.com cast.net 68.42.93.214
            | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
            | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1797 05
            | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
            |
            | Joe,
            |
            | The class is a seperate .cs file included as part of the project.
            | If I switch to the Class View pane I can see both (top level)
            namespaces,
            | and all the class, members, etc below them!
            | If I do ctrl-space I *do* see DataBasementSof tware.... recompile- still
            | nothing.
            |
            |
            | So I deleted the line, ctrl-space will not bring the popup when i have
            an
            | incomplete line such as this.rtbTextToP ass =
            | I deleted the line again. Start with ctrl-space, go through the popup
            | namespaces MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction (
            | then put in the args that displayed, terminated it with ): and then went
            to
            | the start and added the this.rtbTextToP ass = in front of it... recompiled
            | and what do you know... it worked!
            |
            | Went back to the original- checked case and spelling and its identical,
            so I
            | don't know what gives with that!?
            | Thanks for the help though. Have to remember that ctrl-space trick. As a
            | side note- I wish intellisense would always work- I've noticed if you have
            | errors- (ie; forget the ; terminator have mismatched ()'s etc, that it
            will
            | no longer show).
            |
            | Erin.
            |
            |
            | "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
            | news:%23LfEbhDb DHA.3248@tk2msf tngp13.phx.gbl. ..
            | > Is the class in a separate assembly? If so, did you accidently lose
            your
            | > reference? I suppose if you press Ctrl-Space MyCompanyName doesn't
            appear
            | > in the list.
            | >
            | > Joe
            | > --
            | > http://www.csharp-station.com
            | >
            | > "EMonaco" <erinmonaco@nos pam.net> wrote in message
            | > news:uPa$3MDbDH A.1740@TK2MSFTN GP10.phx.gbl...
            | > > Joe,
            | > >
            | > > Done that. Comment out the
            | > > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunc() and it
            | compile
            | > > fine.
            | > > Remove the // and compile and viola, same error as before.... *sigh*
            | > >
            | > >
            | > > Erin.
            | > >
            | > > "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
            | > > news:%23FubPJDb DHA.2032@TK2MSF TNGP10.phx.gbl. ..
            | > > > What you're trying to do looks okay to me. I've had this type of
            | > problem
            | > > > when there was some other type of error in the file, which causes
            | > > > intellisense not to show on the line I'm working with. Maybe you
            | could
            | > > > remove the reference, get a good compile, and try again.
            | > > >
            | > > > Joe
            | > > > --
            | > > > http://www.csharp-station.com
            | > > >
            | > > > "EMonaco" <erinmonaco@nos pam.net> wrote in message
            | > > > news:ONO7q3CbDH A.384@TK2MSFTNG P12.phx.gbl...
            | > > > > All,
            | > > > >
            | > > > > I have a simple C# window app under MyApp namespace it has a
            class
            | > > > Form1.
            | > > > > I've added another class .cs file.
            | > > > > Now this class I want to share with many projects, so I figured
            I'd
            | > > change
            | > > > > this class.cs file from
            | > > > >
            | > > > > namespace MyApp
            | > > > > Class MyClass
            | > > > >
            | > > > > to:
            | > > > > namespace MyCompanyName
            | > > > > namespace LogicalGroup
            | > > > > class MyNewClassName
            | > > > >
            | > > > > In the form class I try
            | > > > > MyCompanyName.L ogicalGroup.MyN ewClassName.thi sstaticfunction ()
            and
            | > it
            | > > > > complains that MyCompanyName namespace could not be found? I
            tried a
            | > > using
            | > > > > MyCompanyName and the namespaces I just created do not show up in
            | > > > > intellisense</> popups.
            | > > > >
            | > > > > Obviously I need to do this a bit differently to get it to work,
            but
            | I
            | > > > don't
            | > > > > want a separate assembly, dll or exe that will need to be
            installed
            | or
            | > > > > copied in order to do this. What am I missing or is there a
            | different
            | > > > route
            | > > > > I need to take?
            | > > > >
            | > > > >
            | > > > > Regards,
            | > > > > Erin.
            | > > > >
            | > > > >
            | > > >
            | > > >
            | > >
            | > >
            | >
            | >
            |
            |
            |

            Comment

            Working...