Deploying c# executables that uses dll's.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    Deploying c# executables that uses dll's.

    Back in the Old days, I compile a C++ executable, copy the dll's used by
    this executable to the same folder. Go to another computer, copy that folder
    locally, double click on the exe file and off we go....

    Today, I have a C# .NET executable, I copied the used .NET dll into the same
    folder. Went to the other computer copied the folder locally. I double click
    on the exe file and a lot of errors that looks like Access violations except
    it is caled differently.

    The Microsoft slogan is no more dll-hell, but this is for me a real dll
    hell. :-(

    So the question now is: how can I make the exe install/register/whatever
    this dll when it discovers that it is not installed yet.
    One sollution is probaly to create a setup project, another is somehow
    manually add this dll, but I wish not to bother any users with these
    additional steps.

    I see a lot of examples for web deployment, on the Internet, but so far
    nothing usefull for normal executables.

    And also interesting, why does the exe startup code not have an check if the
    ..NET frame work is installed or net?
    Back in the Old days, the exe at least told you that you needed Windows in
    order to run this executable (Stub) but the .NET executables today gives
    some wierd error like a missing mscoree.dll or something even scary. And it
    scares the hell out of me every time I meet another computer that has no
    ..NET framework installed.

    Any tips are welcom. :-)

    (I am using C# 2002 version)


  • Jon Skeet

    #2
    Re: Deploying c# executables that uses dll's.

    <Olaf.Baeyens@s kyscan.be> wrote:[color=blue]
    > Back in the Old days, I compile a C++ executable, copy the dll's used by
    > this executable to the same folder. Go to another computer, copy that folder
    > locally, double click on the exe file and off we go....
    >
    > Today, I have a C# .NET executable, I copied the used .NET dll into the same
    > folder. Went to the other computer copied the folder locally. I double click
    > on the exe file and a lot of errors that looks like Access violations except
    > it is caled differently.[/color]

    And what *exactly* is it saying? Without knowing the answer to that,
    it's hard to say what's wrong.
    [color=blue]
    > And also interesting, why does the exe startup code not have an check if the
    > .NET frame work is installed or net?[/color]

    The way that the file is linked would make that quite tricky, I think.

    --
    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

    • Guest's Avatar

      #3
      Re: Deploying c# executables that uses dll's.

      > > Today, I have a C# .NET executable, I copied the used .NET dll into the
      same[color=blue][color=green]
      > > folder. Went to the other computer copied the folder locally. I double[/color][/color]
      click[color=blue][color=green]
      > > on the exe file and a lot of errors that looks like Access violations[/color][/color]
      except[color=blue][color=green]
      > > it is caled differently.[/color]
      >
      > And what *exactly* is it saying? Without knowing the answer to that,
      > it's hard to say what's wrong.[/color]

      Here it comes in a message box, I have no clue what goes wrong.
      ----------
      Title: appl-name - Commom Language Runtime Debugging Services
      Message: Application has generated an exception that could not be handeled.
      Process id=0x3ec (1004), Thread id=0x3a4(932)
      Click OK to terminate the application
      Click CANCEL to debug the application
      ----------

      The machine is Win2000. On my machine where I develop (win2000) this thing
      works perfect.
      I believe that it is because he does not find the .NET dll I also created
      and distributed.
      The odd thing is that this dll is actually at the same location of the exe.
      If this was a normal dll and exe
      then this would work perfect.

      Nothing is wrong in the code since I only start up the form without doing
      fancy stuff.
      At the very least I should have a form with a menu item, some labels and
      some buttons.
      But it crashes even before I see any form at all. Mysterie, mysterie,
      mysterie...
      [color=blue][color=green]
      > > And also interesting, why does the exe startup code not have an check if[/color][/color]
      the[color=blue][color=green]
      > > .NET frame work is installed or net?[/color]
      >
      > The way that the file is linked would make that quite tricky, I think.
      >[/color]
      But far more user friendly.
      But someone that starts to execute this program without the .NET installed
      will probably panic and call IT.
      The last thing I want to do is keep telling people at the phone that they
      need to install .NET first and try again.



      Comment

      • Morten Wennevik

        #4
        Re: Deploying c# executables that uses dll's.

        What do you mean .Net dll, have you installed .Net framework on the target
        machine? When making a C# program you just compile the program into a .exe
        file. Any dll files that belong to .net framework is installed on the
        computer when you install .net framework. No need to include it, but you
        do need to have .net framework installed.

        Also, C# 2002 uses framework v1.0. I'm not sure if the latest framework
        installers also install v1.0 or only v1.1 (2003 version). You may have to
        install framework 1.0 (don't worry it won't overwrite anything v1.1).

        --
        Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

        Comment

        • Jon Skeet

          #5
          Re: Deploying c# executables that uses dll's.

          <Olaf.Baeyens@s kyscan.be> wrote:[color=blue][color=green]
          > > And what *exactly* is it saying? Without knowing the answer to that,
          > > it's hard to say what's wrong.[/color]
          >
          > Here it comes in a message box, I have no clue what goes wrong.
          > ----------
          > Title: appl-name - Commom Language Runtime Debugging Services
          > Message: Application has generated an exception that could not be handeled.
          > Process id=0x3ec (1004), Thread id=0x3a4(932)
          > Click OK to terminate the application
          > Click CANCEL to debug the application
          > ----------[/color]

          Right. That does indeed look nasty. Does it happen on other machines as
          well?
          [color=blue]
          > The machine is Win2000. On my machine where I develop (win2000) this thing
          > works perfect.
          > I believe that it is because he does not find the .NET dll I also created
          > and distributed.
          > The odd thing is that this dll is actually at the same location of the exe.
          > If this was a normal dll and exe then this would work perfect.[/color]

          It should work fine with .NET as well.
          [color=blue][color=green][color=darkred]
          > > > And also interesting, why does the exe startup code not have an check if[/color][/color]
          > the[color=green][color=darkred]
          > > > .NET frame work is installed or net?[/color]
          > >
          > > The way that the file is linked would make that quite tricky, I think.[/color][/color]
          [color=blue]
          > But far more user friendly.
          > But someone that starts to execute this program without the .NET installed
          > will probably panic and call IT.
          > The last thing I want to do is keep telling people at the phone that they
          > need to install .NET first and try again.[/color]

          Well, the same was true for Visual Basic apps - you had to have the
          right version of the runtime for that, too.

          --
          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

          • Ignacio Machin

            #6
            Re: Deploying c# executables that uses dll's.

            Hi,

            <Olaf.Baeyens@s kyscan.be> wrote in message
            news:3f68435b$0 $24158$ba620e4c @reader0.news.s kynet.be...[color=blue]
            > Back in the Old days, I compile a C++ executable, copy the dll's used by
            > this executable to the same folder. Go to another computer, copy that[/color]
            folder[color=blue]
            > locally, double click on the exe file and off we go....
            >
            > Today, I have a C# .NET executable, I copied the used .NET dll into the[/color]
            same[color=blue]
            > folder. Went to the other computer copied the folder locally. I double[/color]
            click[color=blue]
            > on the exe file and a lot of errors that looks like Access violations[/color]
            except[color=blue]
            > it is caled differently.[/color]

            You need to have the framework installed on that machine, otherwise you will
            get an error and the bad part is that it does not say that you need to
            install the framework :(

            [color=blue]
            > The Microsoft slogan is no more dll-hell, but this is for me a real dll
            > hell. :-([/color]

            I think that you are mixing two different things, dll-hell mean that you can
            have several versions of the same dll in the system and that you do not need
            to register those dll as you had to do in the non .net era

            It has nothing to do with the install of the framework on the computer.
            [color=blue]
            > So the question now is: how can I make the exe install/register/whatever
            > this dll when it discovers that it is not installed yet.
            > One sollution is probaly to create a setup project, another is somehow
            > manually add this dll, but I wish not to bother any users with these
            > additional steps.
            >
            > I see a lot of examples for web deployment, on the Internet, but so far
            > nothing usefull for normal executables.[/color]

            You have to distribute the installer to the users, not the copy of the
            directory, if you do a search in google you will find a lot of post saying
            how to do that,
            take a look at this link:



            One thing I have to agree with you, and I really hope they improve it in the
            next version and is that it should exist an option in the setup project
            template to check for the framework. now you have to check it manually , as
            well as checking the correct version of mdac. ( this you also need to have
            in account )


            Hope this help,

            --
            Ignacio Machin,
            ignacio.machin AT dot.state.fl.us
            Florida Department Of Transportation


            Comment

            • Guest's Avatar

              #7
              Re: Deploying c# executables that uses dll's.

              It is my first .NET program that I want to install on a different machine.
              It works perfect on my machine. And it worked perfect on other machines
              before I used this new dll I created.
              [color=blue]
              > installers also install v1.0 or only v1.1 (2003 version). You may have to
              > install framework 1.0 (don't worry it won't overwrite anything v1.1).
              >[/color]
              The complete .NET framework was instaled before I started to test.
              So that is not the problem.
              [color=blue]
              > What do you mean .Net dll, have you installed .Net framework on the target
              > machine? When making a C# program you just compile the program into a[/color]
              ..exe[color=blue]
              > file. Any dll files that belong to .net framework is installed on the
              > computer when you install .net framework. No need to include it, but you
              > do need to have .net framework installed.
              >[/color]

              I was refering to Some.dll that I created in C++ as managed code dll to be
              used in my C# .NET program.
              It works fine on my machine. But I compiled both the dll and the exe code.

              One problem seems to be the "Test.exe.confi g" file that was missing in my
              setup project.
              It would have been nice if I had some messagebox saying that he failed to
              locate some configuration file.

              I already lost half my hair today. ;-)


              Comment

              • Guest's Avatar

                #8
                Re: Deploying c# executables that uses dll's.

                > > > And what *exactly* is it saying? Without knowing the answer to that,[color=blue][color=green][color=darkred]
                > > > it's hard to say what's wrong.[/color]
                > >
                > > Here it comes in a message box, I have no clue what goes wrong.
                > > ----------
                > > Title: appl-name - Commom Language Runtime Debugging Services
                > > Message: Application has generated an exception that could not be[/color][/color]
                handeled.[color=blue][color=green]
                > > Process id=0x3ec (1004), Thread id=0x3a4(932)
                > > Click OK to terminate the application
                > > Click CANCEL to debug the application
                > > ----------[/color]
                >
                > Right. That does indeed look nasty. Does it happen on other machines as
                > well?[/color]

                Yes, XP and Win2000.

                So I am now busy trying to create a setup that also installs this dll and
                ..config file.
                But when I install on the other computers using this setup then I get this
                new error.

                *************** *************
                ----------------------------------
                ************** Exception Text **************
                System.IO.FileN otFoundExceptio n: File or assembly name SkyscanLibBase, or
                one of its dependencies, was not found.
                File name: "SkyscanLibBase "
                at ctRepair.Form1. LoadDatasetInfo rmation()
                at ctRepair.Form1. menuItem2_Click (Object sender, EventArgs e)
                at System.Windows. Forms.MenuItem. OnClick(EventAr gs e)
                at System.Windows. Forms.MenuItemD ata.Execute()
                at System.Windows. Forms.Command.I nvoke()
                at System.Windows. Forms.Control.W mCommand(Messag e& m)
                at System.Windows. Forms.Control.W ndProc(Message& m)
                at System.Windows. Forms.Scrollabl eControl.WndPro c(Message& m)
                at System.Windows. Forms.Container Control.WndProc (Message& m)
                at System.Windows. Forms.Form.WndP roc(Message& m)
                at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
                at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
                at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
                IntPtr wparam, IntPtr lparam)

                === Pre-bind state information ===
                LOG: DisplayName = SkyscanLibBase, Version=1.0.135 4.27798, Culture=neutral ,
                PublicKeyToken= 83aac2de47135ec f
                (Fully-specified)
                LOG: Appbase = C:\Program Files\Skyscan\T ools\CtRepair\
                LOG: Initial PrivatePath = NULL
                Calling assembly : ctRepair, Version=1.0.135 5.22235, Culture=neutral ,
                PublicKeyToken= 83aac2de47135ec f.
                ===

                LOG: Safe mode is set (applyPublisher Policy=no).
                LOG: Host configuration file not found.
                LOG: Using machine configuration file from
                C:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\co nfig\machine.co nfig.
                LOG: Post-policy reference: SkyscanLibBase, Version=1.0.135 4.27798,
                Culture=neutral , PublicKeyToken= 83aac2de47135ec f
                LOG: Attempting download of new URL file:///C:/Program
                Files/Skyscan/Tools/CtRepair/SkyscanLibBase. DLL.
                -------------------------------------
                *************** *************

                The odd thing is that on "file:///C:/Program
                Files/Skyscan/Tools/CtRepair/SkyscanLibBase. DLL" the dll exists.
                SkyscanLibBase. dll is the real name of the used dll.

                I am probably doing something wrong, the question is what.
                The dll is clearly not registered in this .NET framework, but why?
                [color=blue]
                > It should work fine with .NET as well.
                >[/color]
                In theorie: yes. ;-)

                PS: I call this dll-hell since it is a dll and I have a hell of a time. ;-)
                Anyway, I have at least a lot of fun, trying to install a simple .NET
                program.
                I hope these issues will get resolved by the time I have a commercial
                release version.



                Comment

                • Jon Skeet

                  #9
                  Re: Deploying c# executables that uses dll's.

                  <Olaf.Baeyens@s kyscan.be> wrote:

                  <snip>
                  [color=blue]
                  > LOG: DisplayName = SkyscanLibBase, Version=1.0.135 4.27798, Culture=neutral ,
                  > PublicKeyToken= 83aac2de47135ec f
                  > (Fully-specified)
                  > LOG: Appbase = C:\Program Files\Skyscan\T ools\CtRepair\
                  > LOG: Initial PrivatePath = NULL
                  > Calling assembly : ctRepair, Version=1.0.135 5.22235, Culture=neutral ,
                  > PublicKeyToken= 83aac2de47135ec f.[/color]

                  Those version numbers look like they may well be the problem. If you've
                  got fully-qualified version numbers, it may be looking for the exact
                  same version, and failing to find it.

                  --
                  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

                  • Guest's Avatar

                    #10
                    Re: Deploying c# executables that uses dll's.

                    > > LOG: DisplayName = SkyscanLibBase, Version=1.0.135 4.27798,
                    Culture=neutral ,[color=blue][color=green]
                    > > PublicKeyToken= 83aac2de47135ec f
                    > > (Fully-specified)
                    > > LOG: Appbase = C:\Program Files\Skyscan\T ools\CtRepair\
                    > > LOG: Initial PrivatePath = NULL
                    > > Calling assembly : ctRepair, Version=1.0.135 5.22235, Culture=neutral ,
                    > > PublicKeyToken= 83aac2de47135ec f.[/color]
                    >
                    > Those version numbers look like they may well be the problem. If you've
                    > got fully-qualified version numbers, it may be looking for the exact
                    > same version, and failing to find it.[/color]

                    I think that you have pointed me to the correct direction. :-)
                    I am checking this out right now.

                    thanks. :-)


                    Comment

                    • Jeff Molby

                      #11
                      Re: Deploying c# executables that uses dll's.


                      "Morten Wennevik" <mortenwennevik @hotmail.com> wrote in message
                      news:oprvm9qcj9 ge0n9a@localhos t...[color=blue]
                      > What do you mean .Net dll, have you installed .Net framework on the target
                      > machine? When making a C# program you just compile the program into a[/color]
                      ..exe[color=blue]
                      > file. Any dll files that belong to .net framework is installed on the
                      > computer when you install .net framework. No need to include it, but you
                      > do need to have .net framework installed.[/color]

                      I think he's referring to a custom DLL that he developed in C# that his
                      application depends on. However, it sounds like it should work as is. DLLs
                      in the application directory are found automatically. I bet the culprit is
                      an incorrect version of the framework.[color=blue]
                      >
                      > Also, C# 2002 uses framework v1.0. I'm not sure if the latest framework
                      > installers also install v1.0 or only v1.1 (2003 version). You may have to
                      > install framework 1.0 (don't worry it won't overwrite anything v1.1).[/color]

                      I'm pretty sure they are seperate installations


                      Comment

                      • Guest's Avatar

                        #12
                        Re: Deploying c# executables that uses dll's.

                        > I think he's referring to a custom DLL that he developed in C# that his[color=blue]
                        > application depends on. However, it sounds like it should work as is. DLLs
                        > in the application directory are found automatically. I bet the culprit is
                        > an incorrect version of the framework.[color=green]
                        > >
                        > > Also, C# 2002 uses framework v1.0. I'm not sure if the latest framework
                        > > installers also install v1.0 or only v1.1 (2003 version). You may have[/color][/color]
                        to[color=blue][color=green]
                        > > install framework 1.0 (don't worry it won't overwrite anything v1.1).[/color]
                        >
                        > I'm pretty sure they are seperate installations
                        >[/color]
                        I just did install 1.0, but no solution.

                        I also checked these versions, but

                        SkyscanLibBase, Version=1.0.135 4.27798
                        ctRepair, Version=1.0.135 5.22235

                        But I do not think that these versions have anything to do with the problem.
                        If I understand the version numbers correctly then ctRepair has
                        Version=1.0.135 5.22235 and expects SkyscanLibBase with
                        Version=1.0.135 4.27798

                        My ctRepair assembly file these settings

                        [assembly: AssemblyVersion ("1.0.*")]
                        [assembly: AssemblyDelaySi gn(false)]
                        [assembly: AssemblyKeyFile ("..\\..\\Skysc an.snk")]
                        [assembly: AssemblyKeyName ("")]

                        Today I give up.
                        Maybe some time in te future I wish to try again.
                        One thing that I might do is to move to C# v2003 to see if this corrects the
                        problem.

                        Thanks all for the feed-back. :-)



                        Comment

                        • Jon Skeet

                          #13
                          Re: Deploying c# executables that uses dll's.

                          <Olaf.Baeyens@s kyscan.be> wrote:[color=blue]
                          > I just did install 1.0, but no solution.
                          >
                          > I also checked these versions, but
                          >
                          > SkyscanLibBase, Version=1.0.135 4.27798
                          > ctRepair, Version=1.0.135 5.22235
                          >
                          > But I do not think that these versions have anything to do with the problem.
                          > If I understand the version numbers correctly then ctRepair has
                          > Version=1.0.135 5.22235 and expects SkyscanLibBase with
                          > Version=1.0.135 4.27798[/color]

                          Look at ctRepair with ildasm - in the manifest it should say which
                          version it's expecting.

                          --
                          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

                          • Guest's Avatar

                            #14
                            Re: Deploying c# executables that uses dll's.

                            > > SkyscanLibBase, Version=1.0.135 4.27798[color=blue][color=green]
                            > > ctRepair, Version=1.0.135 5.22235
                            > >
                            > > But I do not think that these versions have anything to do with the[/color][/color]
                            problem.[color=blue][color=green]
                            > > If I understand the version numbers correctly then ctRepair has
                            > > Version=1.0.135 5.22235 and expects SkyscanLibBase with
                            > > Version=1.0.135 4.27798[/color]
                            >
                            > Look at ctRepair with ildasm - in the manifest it should say which
                            > version it's expecting.
                            >[/color]
                            I checked at my home computer and there it installed without troubles.
                            When I copied the folder and the execute ctRepair (before using any
                            installer) then the program started up without problems, but gave an error
                            once I used a function found in this SkyscanLibBase. dll.

                            Then I installed the software using the installer and it worked perfectt!
                            The dll was known.

                            So far I can tell that computers that have VC++ .NET installed have no
                            problems to run the program, but computers that never had VC++ .NET
                            installed have this big problem not finding the dll.
                            One thing comes to mind is that the DLL build in VC++ 2002, is build with
                            MFC as dll, not static.
                            Could this be the cause of it? And where can I find this mfc dll? Up untill
                            now I always used static linking of mfc.
                            But in order to build the .NET managed dll, I had to build with mfc in a
                            dynamic library.

                            Thanks for any feed-back. :-)
                            Olaf


                            Comment

                            • Guest's Avatar

                              #15
                              Re: Deploying c# executables that uses dll's.

                              > So far I can tell that computers that have VC++ .NET installed have no[color=blue]
                              > problems to run the program, but computers that never had VC++ .NET
                              > installed have this big problem not finding the dll.
                              > One thing comes to mind is that the DLL build in VC++ 2002, is build with
                              > MFC as dll, not static.
                              > Could this be the cause of it? And where can I find this mfc dll? Up[/color]
                              untill[color=blue]
                              > now I always used static linking of mfc.
                              > But in order to build the .NET managed dll, I had to build with mfc in a
                              > dynamic library.
                              >[/color]
                              Just checked, it appears that the .NET framework 1.0 comes with MFC 70
                              installed
                              and the 1.1 comes with MFC71 installed. So back to the drawingboard. :-(

                              Today I give up searching to solve this problem. Maybe some other time.

                              (I love the .NET framweork though)


                              Comment

                              Working...