DLL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • [GHO]

    #1

    DLL

    Can some one send me a sample DLL file which wrote in C#
    language.
  • Adrian Vinca [MSFT]

    #2
    RE: DLL

    You could take a look on:
    http://msdn.microsoft.com/library/de...us/csspec/html
    /vclrfcsharpspec _1_12.asp

    In Visual Studio .NET:

    Create your dll by using File -> New Project and than select from the
    dialog:
    - Project Type: "Visual C# Projects"
    - Template: "Class Library"
    - Type a name, select a location and press OK
    Type your code and build. You will have your own dll.

    Using the dll in your exe:
    - Create your C# application
    - Go into the Solution Explorer, right click on your project and select
    "Add Reference". Than use Browse to locate your dll. After that you will be
    able to use the classes and functions defined in your dll.

    http://msdn.microsoft.com/library/de...us/vbcon/html/
    vbtskaddingremo vingreferences. asp

    Note: If the namespaces are different, you will have to add an "using"
    directive into your exe code.
    [color=blue]
    >
    >Can some one send me a sample DLL file which wrote in C#
    >language.
    >[/color]

    Adrian Vinca [MSFT], Developer Division
    --------------------------------------------------------------------
    This reply is provided "AS IS", without warranty (express or implied).

    Note: For the benefit of the community-at-large, all responses to this
    message are best directed to the newsgroup/thread from which they
    originated.

    Comment

    • Yosi Katib

      #3
      RE: DLL



      I know All you sent me, but my problem is to create a general DLL, as on
      MFC to be able to use it from any application not only C# application.

      I always create MFC DLL , then add the *.lib then
      "exten myDLLfunc()" , then copy my DLL to Aplication directory,
      Now I can use this function.

      Now what I'm asking for is how to do that by using C# language to create
      a DLL file then using this DLL on MFC application

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Sunny

        #4
        RE: DLL

        Hi Yosi,
        So, you need to read about interop, and exposing .net assemblies to COM.

        In general you have to right-click on your project, select
        Properties/Configuration properties/Build, and there change Register for
        Com interop to true.

        Than, when you build the assembly, it will be registered, and you can
        use that classes.

        Actually this is simplest solution for beginning. This way the assembly
        will be registered only on the dev machine.

        If you want to distribute this with your app on other machines there are
        2 possible solutions:
        1. use a setup project from VS.Net, and on the properties of the dll
        (when you add it there) set Register = vsdrpCOM. It should make all
        necessary preparations.

        2. If the first solution fails (it happen to me, so now I use this),
        your install script have to run:
        regasm.exe mydll.dll /tlb:myddl.tlb /codebase /silent

        /codebase registers the dll for COM interop without the need of putting
        your dll in GAC. This is not the recommended by MS way, but you may use
        it.
        You can do it without /codebase, but then your install script have to
        install the dll in GAC.

        This are only shortcuts, but before doing such a things I strongly
        recommend to read the articles in MSDN, related to Interop, like:

        http://msdn.microsoft.com/library/de...l=/library/en-
        us/vbcon/html/vbconcominterop invisualbasicvi sualc.asp

        and search Google for more. I found this one helpful:

        http://www.c-sharpcorner.com/Code/20...nteropP2AJ.asp

        Have fun
        Cheers
        Sunny

        In article <e8705izrDHA.23 64@TK2MSFTNGP09 .phx.gbl>,
        yousefk@taux01. nsc.com says...[color=blue]
        >
        >
        > I know All you sent me, but my problem is to create a general DLL, as on
        > MFC to be able to use it from any application not only C# application.
        >
        > I always create MFC DLL , then add the *.lib then
        > "exten myDLLfunc()" , then copy my DLL to Aplication directory,
        > Now I can use this function.
        >
        > Now what I'm asking for is how to do that by using C# language to create
        > a DLL file then using this DLL on MFC application
        >
        > *** Sent via Developersdex http://www.developersdex.com ***
        > Don't just participate in USENET...get rewarded for it!
        >[/color]

        Comment

        • [Joe]

          #5
          RE: DLL

          Why this not working well in WIN98????
          [color=blue]
          >-----Original Message-----
          >Hi Yosi,
          >So, you need to read about interop, and exposing .net[/color]
          assemblies to COM.[color=blue]
          >
          >In general you have to right-click on your project,[/color]
          select[color=blue]
          >Properties/Configuration properties/Build, and there[/color]
          change Register for[color=blue]
          >Com interop to true.
          >
          >Than, when you build the assembly, it will be registered,[/color]
          and you can[color=blue]
          >use that classes.
          >
          >Actually this is simplest solution for beginning. This[/color]
          way the assembly[color=blue]
          >will be registered only on the dev machine.
          >
          >If you want to distribute this with your app on other[/color]
          machines there are[color=blue]
          >2 possible solutions:
          >1. use a setup project from VS.Net, and on the properties[/color]
          of the dll[color=blue]
          >(when you add it there) set Register = vsdrpCOM. It[/color]
          should make all[color=blue]
          >necessary preparations.
          >
          >2. If the first solution fails (it happen to me, so now I[/color]
          use this),[color=blue]
          >your install script have to run:
          >regasm.exe mydll.dll /tlb:myddl.tlb /codebase /silent
          >
          >/codebase registers the dll for COM interop without the[/color]
          need of putting[color=blue]
          >your dll in GAC. This is not the recommended by MS way,[/color]
          but you may use[color=blue]
          >it.
          >You can do it without /codebase, but then your install[/color]
          script have to[color=blue]
          >install the dll in GAC.
          >
          >This are only shortcuts, but before doing such a things I[/color]
          strongly[color=blue]
          >recommend to read the articles in MSDN, related to[/color]
          Interop, like:[color=blue]
          >
          >http://msdn.microsoft.com/library/default.asp?[/color]
          url=/library/en-[color=blue]
          >us/vbcon/html/vbconcominterop invisualbasicvi sualc.asp
          >
          >and search Google for more. I found this one helpful:
          >
          >http://www.c-[/color]
          sharpcorner.com/Code/2002/April/COMInteropP2AJ. asp[color=blue]
          >
          >Have fun
          >Cheers
          >Sunny
          >
          >In article <e8705izrDHA.23 64@TK2MSFTNGP09 .phx.gbl>,
          >yousefk@taux01 .nsc.com says...[color=green]
          >>
          >>
          >> I know All you sent me, but my problem is to create a[/color][/color]
          general DLL, as on[color=blue][color=green]
          >> MFC to be able to use it from any application not only[/color][/color]
          C# application.[color=blue][color=green]
          >>
          >> I always create MFC DLL , then add the *.lib then
          >> "exten myDLLfunc()" , then copy my DLL to Aplication[/color][/color]
          directory,[color=blue][color=green]
          >> Now I can use this function.
          >>
          >> Now what I'm asking for is how to do that by using C#[/color][/color]
          language to create[color=blue][color=green]
          >> a DLL file then using this DLL on MFC application
          >>
          >> *** Sent via Developersdex http://www.developersdex.com[/color][/color]
          ***[color=blue][color=green]
          >> Don't just participate in USENET...get rewarded for it!
          >>[/color]
          >.
          >[/color]

          Comment

          • Alvin Bruney

            #6
            Re: DLL

            Whats win98?

            *end sarcasm*

            "[Joe]" <yousefk@taux01 .nsc.com> wrote in message
            news:0f1801c3b7 3f$afd72100$7d0 2280a@phx.gbl.. .[color=blue]
            > Why this not working well in WIN98????
            >[color=green]
            > >-----Original Message-----
            > >Hi Yosi,
            > >So, you need to read about interop, and exposing .net[/color]
            > assemblies to COM.[color=green]
            > >
            > >In general you have to right-click on your project,[/color]
            > select[color=green]
            > >Properties/Configuration properties/Build, and there[/color]
            > change Register for[color=green]
            > >Com interop to true.
            > >
            > >Than, when you build the assembly, it will be registered,[/color]
            > and you can[color=green]
            > >use that classes.
            > >
            > >Actually this is simplest solution for beginning. This[/color]
            > way the assembly[color=green]
            > >will be registered only on the dev machine.
            > >
            > >If you want to distribute this with your app on other[/color]
            > machines there are[color=green]
            > >2 possible solutions:
            > >1. use a setup project from VS.Net, and on the properties[/color]
            > of the dll[color=green]
            > >(when you add it there) set Register = vsdrpCOM. It[/color]
            > should make all[color=green]
            > >necessary preparations.
            > >
            > >2. If the first solution fails (it happen to me, so now I[/color]
            > use this),[color=green]
            > >your install script have to run:
            > >regasm.exe mydll.dll /tlb:myddl.tlb /codebase /silent
            > >
            > >/codebase registers the dll for COM interop without the[/color]
            > need of putting[color=green]
            > >your dll in GAC. This is not the recommended by MS way,[/color]
            > but you may use[color=green]
            > >it.
            > >You can do it without /codebase, but then your install[/color]
            > script have to[color=green]
            > >install the dll in GAC.
            > >
            > >This are only shortcuts, but before doing such a things I[/color]
            > strongly[color=green]
            > >recommend to read the articles in MSDN, related to[/color]
            > Interop, like:[color=green]
            > >
            > >http://msdn.microsoft.com/library/default.asp?[/color]
            > url=/library/en-[color=green]
            > >us/vbcon/html/vbconcominterop invisualbasicvi sualc.asp
            > >
            > >and search Google for more. I found this one helpful:
            > >
            > >http://www.c-[/color]
            > sharpcorner.com/Code/2002/April/COMInteropP2AJ. asp[color=green]
            > >
            > >Have fun
            > >Cheers
            > >Sunny
            > >
            > >In article <e8705izrDHA.23 64@TK2MSFTNGP09 .phx.gbl>,
            > >yousefk@taux01 .nsc.com says...[color=darkred]
            > >>
            > >>
            > >> I know All you sent me, but my problem is to create a[/color][/color]
            > general DLL, as on[color=green][color=darkred]
            > >> MFC to be able to use it from any application not only[/color][/color]
            > C# application.[color=green][color=darkred]
            > >>
            > >> I always create MFC DLL , then add the *.lib then
            > >> "exten myDLLfunc()" , then copy my DLL to Aplication[/color][/color]
            > directory,[color=green][color=darkred]
            > >> Now I can use this function.
            > >>
            > >> Now what I'm asking for is how to do that by using C#[/color][/color]
            > language to create[color=green][color=darkred]
            > >> a DLL file then using this DLL on MFC application
            > >>
            > >> *** Sent via Developersdex http://www.developersdex.com[/color][/color]
            > ***[color=green][color=darkred]
            > >> Don't just participate in USENET...get rewarded for it!
            > >>[/color]
            > >.
            > >[/color][/color]


            Comment

            • Yosi Katib

              #7
              Re: DLL


              Win98 = windows 98 OS


              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • Alvin Bruney

                #8
                Re: DLL

                OMG REALLY!!!

                I would consider .NET support on 9x as you get what you get if any.

                "Yosi Katib" <yousefk@taux01 .nsc.com> wrote in message
                news:uXFeX29tDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
                >
                > Win98 = windows 98 OS
                >
                >
                > *** Sent via Developersdex http://www.developersdex.com ***
                > Don't just participate in USENET...get rewarded for it![/color]


                Comment

                Working...