dcsimg
Results 1 to 5 of 5

Thread: Deploying dll to fixed location

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    40

    Deploying dll to fixed location

    I have moved some functionality in my vb.net (vs2015) desktop app that I would like to be able to change dynamically to a dll created in a different project. The idea is to be able to distribute a new dll to users to upgrade functionality, kind of a patch (but aimed at customizing rather than updating).

    Experimenting, since the application directory is read only, I have registered the dll in a folder of my choosing (by adding reference from my main project) and created an interface to replace the dll at runtime from within my app. This works fine. To actually make it work I now need to be able to have my setup project copy the dll to some location (preferably a folder in C:\Users\Public where I am already placing a database used by the app) from where my app will find it. How would I go about that?

    Sorry for not presenting a lot of info about what I have already tried. I attempted to simply put the dll in the same file system folder in the setup project where the database is copied from. That didnt work and it broke all my dependencies. I now have to rebuild the setup project from scratch and I thought I would ask before I wreck everything again.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,975

    Re: Deploying dll to fixed location

    I've never tried this but I think that deploying the file should be like any other file, e.g. your database, but it's then a matter of telling the Framework to look in the right place for it. From past experience, I know that "probing" is an important keyword on this topic so I just performed this search:

    https://www.bing.com/search?q=.net+p...8a1jnJ&plvar=0

    In case your result vary, the first two results seem potentially relevant:

    https://docs.microsoft.com/en-us/dot...tes-assemblies
    https://stackoverflow.com/questions/...runtime-in-net

    At a glance, there are other results there that may help too.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    40

    Re: Deploying dll to fixed location

    A little update on what Ive managed to do.

    Starting from the links provided by jmcilhinney, I found a good looking solution here:

    https://support.microsoft.com/sv-se/...folder-that-is

    I tried the third method: exploiting the AssemblyResolve event to locate my dll.

    I had this solution working at design time, with my assembly file still in a folder chosen by me. After using my setup project to install the app, it still worked in the sense that the app couldnt find the dll, fired the AssemblyResolve event and was able to bind to the assembly. However, even though the dll was set to CopyLocal = False, I cound not prevent the application from placing a copy in the application directory, and then this copy was used so that the AssemblyResolve was never fired when I swiched the dll. I will leave the theread as is, if someone finds a solution.

    I solved my specific problem by finding a way around the read only problem, renaming the assembly in the app directory and then adding a new copy. The renamed dll will be used untill the app is restarted, then it will load the new one. Works for my specific problem but i suppose it could cause problems in other situations.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,975

    Re: Deploying dll to fixed location

    What installer technology are you using? Is it the standard Setup project template that comes standard with VS 2010? I find it hard to believe that there's no way to stop that DLL being included in the output but I don't have VS 2010 to test on.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    40

    Re: Deploying dll to fixed location

    Yes, it is the standard setup, vs2015 though. Im sure that it is me who is ****, but I cant think what I would do differently.

    I registered the dll in an arbitrary folder, which is where I also set the path for the version included in the setup, and set Copy Local to False in Properties. Then I built the solution and removed the dll from the arbitrary folder so that the only version on my system was the one included in the setup files (also checked that there was no instance of it in the bin folder). After installing, there was a copy in the app folder. I tried to remove it manually, but a new copy was there the next time I ran the app.

    Since I solved my problem I will not explore it further. I hope the next person who tries solves it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width