dwmkerr / sharpshell

SharpShell makes it easy to create Windows Shell Extensions using the .NET Framework.
MIT License
1.49k stars 261 forks source link

Are there limits in using more external libraries? E.g. make a call to a db via a seperate .dll to get the info for CanShowOverlay? #278

Open MPasadu opened 5 years ago

MPasadu commented 5 years ago

Hey,

I was experimenting with SharpShell and I tried to make a DB call through a external library (neo4jdriver.dll - graph db driver library) inside CanShowOverlay.

How does it work in general when you want to use external dlls / more nuget packages inside the implementation of SharpIconOverlayHandler? Can you just add them to the project and that's it?

dwmkerr commented 5 years ago

Hi @MPasadu this should work absolutely fine. However, for any external libraries, when you release to the target machine you should make sure that those libraries are installed into the Global Assembly Cache. The basic Windows Installer project you can use from Visual Studio lets you do this easily.

One thing - for an assembly to be added to the GAC, it must have a strong name, i.e. it must be signed! For something like the neo4j driver this should not be a problem, but if you are building your own personal libraries, just remember to sign them.

Give it a try and let me know how it goes, if there are any problems add the info to this issue. If not, I can add these notes to the docs.

MPasadu commented 5 years ago

@dwmkerr Thank you I will give it a try! I'll report back (probably at the end of the week).

Do you advise to install all the dependency libraries into the GAC? Or would it be better to make the SharpIconOverlayHandler call another program(.exe) which has all the libraries and will just do whatever has to be done and return true/false?

dwmkerr commented 5 years ago

Cool, let me know how it goes! It'd say the options are:

  1. Install in the GAC, clean and simple, but maybe a little harder for installer
  2. Run an exe. Also simple-ish, but you need to know how you will work out the path to the executable, and also running a process on Windows can be a little slow so it is possible that the time involved in startup/shutdown of the process might slow the shell down a bit
  3. Instead of an exe, run a Windows Service, then connect via WCF (either via TCP/IP or named pipes) and call that. This has the benefit of not having startup/shutdown time but is likely much faster

Option 3 is much closer to a 'client -> server' model, and for something complex might work, but it sounds like what would probably be easiest would be to have the assemblies in the GAC. The final option (I think) would be to simply keep the dlls adjacent to your dll when you install, and install with the /Codebase flag (see https://github.com/dwmkerr/sharpshell/blob/master/docs/installing/installing.md#install-not-using-the-gac). This should work too!

Countryen commented 5 years ago

Hey @MPasadu, was this problem resolved for you or do you still have questions? I would like to close this issue, if okay.

But please don't close it immediately as I first want to see, if the information here could be added to the docs, as I don't think it is in there already.

MPasadu commented 5 years ago

We went with nr3. A co-worker implemented a prototype but the project is on hold for now.