Calling C# from VB.Net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kevininstructor@state.or.us

    Calling C# from VB.Net

    Hello,

    I have code in a C# file which I want to call the class within from a VB
    DotNet form. The code is from
    http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi and
    web developer.

    I tried using "Imports" but didn't show up when doing the dot operator
    thing.

    Thanks for any assistance!!!
    Kevin


  • Norman Yuan

    #2
    Re: Calling C# from VB.Net

    You first have to build the C# code in its own project into a *.dll file and
    then you set reference to it in the calling VB.NET project. You cannot use
    different language in the same project.

    "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
    message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hello,
    >
    > I have code in a C# file which I want to call the class within from a VB
    > DotNet form. The code is from
    > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
    and[color=blue]
    > web developer.
    >
    > I tried using "Imports" but didn't show up when doing the dot operator
    > thing.
    >
    > Thanks for any assistance!!!
    > Kevin
    >
    >[/color]


    Comment

    • Norman Yuan

      #3
      Re: Calling C# from VB.Net

      You first have to build the C# code in its own project into a *.dll file and
      then you set reference to it in the calling VB.NET project. You cannot use
      different language in the same project.

      "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
      message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Hello,
      >
      > I have code in a C# file which I want to call the class within from a VB
      > DotNet form. The code is from
      > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
      and[color=blue]
      > web developer.
      >
      > I tried using "Imports" but didn't show up when doing the dot operator
      > thing.
      >
      > Thanks for any assistance!!!
      > Kevin
      >
      >[/color]


      Comment

      • Cowboy \(Gregory A. Beamer\) [MVP]

        #4
        Re: Calling C# from VB.Net

        Put the C# file into another project (class library) and add a project
        reference in the VB.NET web app. You cannot mix languages in a single
        project (at least not until VS.NET 2005).

        --
        Gregory A. Beamer
        MVP; MCP: +I, SE, SD, DBA

        *************** *************** *************** *************** ***
        Think outside the box!
        *************** *************** *************** *************** ***
        "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
        message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=blue]
        > Hello,
        >
        > I have code in a C# file which I want to call the class within from a VB
        > DotNet form. The code is from
        > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
        and[color=blue]
        > web developer.
        >
        > I tried using "Imports" but didn't show up when doing the dot operator
        > thing.
        >
        > Thanks for any assistance!!!
        > Kevin
        >
        >[/color]


        Comment

        • Cowboy \(Gregory A. Beamer\) [MVP]

          #5
          Re: Calling C# from VB.Net

          Put the C# file into another project (class library) and add a project
          reference in the VB.NET web app. You cannot mix languages in a single
          project (at least not until VS.NET 2005).

          --
          Gregory A. Beamer
          MVP; MCP: +I, SE, SD, DBA

          *************** *************** *************** *************** ***
          Think outside the box!
          *************** *************** *************** *************** ***
          "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
          message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Hello,
          >
          > I have code in a C# file which I want to call the class within from a VB
          > DotNet form. The code is from
          > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
          and[color=blue]
          > web developer.
          >
          > I tried using "Imports" but didn't show up when doing the dot operator
          > thing.
          >
          > Thanks for any assistance!!!
          > Kevin
          >
          >[/color]


          Comment

          • Tian Min Huang

            #6
            RE: Calling C# from VB.Net

            Hi Kevin,

            Thanks for your post. As suggested by Norman and Gregory, you will need to
            put C# file in a separate project (class library). In addition, please
            refer to the following MSDN articles for the sample and detailed
            information:

            Cross-Language Inheritance


            C# and the .NET Platform - Chapter 6


            Hope this helps.

            Regards,

            HuangTM
            Microsoft Online Partner Support
            MCSE/MCSD

            Get Secure! -- www.microsoft.com/security
            This posting is provided "as is" with no warranties and confers no rights.

            Comment

            • Tian Min Huang

              #7
              RE: Calling C# from VB.Net

              Hi Kevin,

              Thanks for your post. As suggested by Norman and Gregory, you will need to
              put C# file in a separate project (class library). In addition, please
              refer to the following MSDN articles for the sample and detailed
              information:

              Cross-Language Inheritance


              C# and the .NET Platform - Chapter 6


              Hope this helps.

              Regards,

              HuangTM
              Microsoft Online Partner Support
              MCSE/MCSD

              Get Secure! -- www.microsoft.com/security
              This posting is provided "as is" with no warranties and confers no rights.

              Comment

              • kevininstructor@state.or.us

                #8
                Re: Calling C# from VB.Net

                Thanks Norm!

                "Norman Yuan" <normanyuan@Rem oveThis.shaw.ca > wrote in message
                news:KzZec.1079 70$Ig.94883@pd7 tw2no...[color=blue]
                > You first have to build the C# code in its own project into a *.dll file[/color]
                and[color=blue]
                > then you set reference to it in the calling VB.NET project. You cannot use
                > different language in the same project.
                >
                > "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
                > message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=green]
                > > Hello,
                > >
                > > I have code in a C# file which I want to call the class within from a VB
                > > DotNet form. The code is from
                > > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
                > and[color=green]
                > > web developer.
                > >
                > > I tried using "Imports" but didn't show up when doing the dot operator
                > > thing.
                > >
                > > Thanks for any assistance!!!
                > > Kevin
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • kevininstructor@state.or.us

                  #9
                  Re: Calling C# from VB.Net

                  Thanks Norm!

                  "Norman Yuan" <normanyuan@Rem oveThis.shaw.ca > wrote in message
                  news:KzZec.1079 70$Ig.94883@pd7 tw2no...[color=blue]
                  > You first have to build the C# code in its own project into a *.dll file[/color]
                  and[color=blue]
                  > then you set reference to it in the calling VB.NET project. You cannot use
                  > different language in the same project.
                  >
                  > "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
                  > message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=green]
                  > > Hello,
                  > >
                  > > I have code in a C# file which I want to call the class within from a VB
                  > > DotNet form. The code is from
                  > > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
                  > and[color=green]
                  > > web developer.
                  > >
                  > > I tried using "Imports" but didn't show up when doing the dot operator
                  > > thing.
                  > >
                  > > Thanks for any assistance!!!
                  > > Kevin
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • kevininstructor@state.or.us

                    #10
                    Re: Calling C# from VB.Net

                    Thanks Cowboy!

                    "Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld @comcast.netNoS pamM> wrote
                    in message news:eoDqczbIEH A.3536@TK2MSFTN GP09.phx.gbl...[color=blue]
                    > Put the C# file into another project (class library) and add a project
                    > reference in the VB.NET web app. You cannot mix languages in a single
                    > project (at least not until VS.NET 2005).
                    >
                    > --
                    > Gregory A. Beamer
                    > MVP; MCP: +I, SE, SD, DBA
                    >
                    > *************** *************** *************** *************** ***
                    > Think outside the box!
                    > *************** *************** *************** *************** ***
                    > "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
                    > message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=green]
                    > > Hello,
                    > >
                    > > I have code in a C# file which I want to call the class within from a VB
                    > > DotNet form. The code is from
                    > > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
                    > and[color=green]
                    > > web developer.
                    > >
                    > > I tried using "Imports" but didn't show up when doing the dot operator
                    > > thing.
                    > >
                    > > Thanks for any assistance!!!
                    > > Kevin
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • kevininstructor@state.or.us

                      #11
                      Re: Calling C# from VB.Net

                      Thanks Cowboy!

                      "Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld @comcast.netNoS pamM> wrote
                      in message news:eoDqczbIEH A.3536@TK2MSFTN GP09.phx.gbl...[color=blue]
                      > Put the C# file into another project (class library) and add a project
                      > reference in the VB.NET web app. You cannot mix languages in a single
                      > project (at least not until VS.NET 2005).
                      >
                      > --
                      > Gregory A. Beamer
                      > MVP; MCP: +I, SE, SD, DBA
                      >
                      > *************** *************** *************** *************** ***
                      > Think outside the box!
                      > *************** *************** *************** *************** ***
                      > "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
                      > message news:uM2SuGZIEH A.2164@TK2MSFTN GP12.phx.gbl...[color=green]
                      > > Hello,
                      > >
                      > > I have code in a C# file which I want to call the class within from a VB
                      > > DotNet form. The code is from
                      > > http://www.dnzone.com/ShowDetail.asp?NewsId=223. I am a more of a Delphi[/color]
                      > and[color=green]
                      > > web developer.
                      > >
                      > > I tried using "Imports" but didn't show up when doing the dot operator
                      > > thing.
                      > >
                      > > Thanks for any assistance!!!
                      > > Kevin
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • kevininstructor@state.or.us

                        #12
                        Re: Calling C# from VB.Net

                        Thanks Tian for the links and intel!

                        "Tian Min Huang" <timhuang@onlin e.microsoft.com > wrote in message
                        news:1tix$fcIEH A.348@cpmsftngx a06.phx.gbl...[color=blue]
                        > Hi Kevin,
                        >
                        > Thanks for your post. As suggested by Norman and Gregory, you will need to
                        > put C# file in a separate project (class library). In addition, please
                        > refer to the following MSDN articles for the sample and detailed
                        > information:
                        >
                        > Cross-Language Inheritance
                        > http://www.vbip.com/books/1861004915...er_4915_12.asp
                        >
                        > C# and the .NET Platform - Chapter 6
                        > http://www.codeproject.com/books/1893115593_6.asp
                        >
                        > Hope this helps.
                        >
                        > Regards,
                        >
                        > HuangTM
                        > Microsoft Online Partner Support
                        > MCSE/MCSD
                        >
                        > Get Secure! -- www.microsoft.com/security
                        > This posting is provided "as is" with no warranties and confers no rights.
                        >[/color]


                        Comment

                        • kevininstructor@state.or.us

                          #13
                          Re: Calling C# from VB.Net

                          Thanks Tian for the links and intel!

                          "Tian Min Huang" <timhuang@onlin e.microsoft.com > wrote in message
                          news:1tix$fcIEH A.348@cpmsftngx a06.phx.gbl...[color=blue]
                          > Hi Kevin,
                          >
                          > Thanks for your post. As suggested by Norman and Gregory, you will need to
                          > put C# file in a separate project (class library). In addition, please
                          > refer to the following MSDN articles for the sample and detailed
                          > information:
                          >
                          > Cross-Language Inheritance
                          > http://www.vbip.com/books/1861004915...er_4915_12.asp
                          >
                          > C# and the .NET Platform - Chapter 6
                          > http://www.codeproject.com/books/1893115593_6.asp
                          >
                          > Hope this helps.
                          >
                          > Regards,
                          >
                          > HuangTM
                          > Microsoft Online Partner Support
                          > MCSE/MCSD
                          >
                          > Get Secure! -- www.microsoft.com/security
                          > This posting is provided "as is" with no warranties and confers no rights.
                          >[/color]


                          Comment

                          Working...