GAC_MSIL and Shell Extensions - c#

I've trying to develop while also creating a COM .DLL for my shell icon overlay and context stuff, so i do some search on the tool to make this happens, then i found SharpShell, the shell extension helper tool.
I've been using sharpshell to create an example .DLL, once its generated, i used their "Server Manager" to automatically helps register my .DLL to the registry and the server is loaded properly.
On the Registry, I've seen them registered properly, but i don't see any change in my UI. So i tried to download "Shell Ext Viewer - Shexview - 64 Bit. "
After i opened my shell lists, i saw my Dll was registered there, but they are reading my .DLL files in C:\Windows\Assembly\GAC_MSIL\ folder.
So i tried browsing them in in my Explorer, but i find out that i dont have GAC Assembly.
I further checked articles for help, i found out that they're .nEt extensions, and i also checked my .NET, all of the .NETs from 4.0 are installed properly, but i dont have GAC_MSIL in my assembly. What should i do in order to tell my Shell to open my dll file into a correct file? is there any a way from visual studio where can i register my Dll and server to a specified folder, instead of GAC_MSIL folder, because i am missing it?
Thank you, and i would really appreciate your help !

There are some limitations for OverlayIcons. You have only 15 slots for OverlayIcons. If you have Dropbox or Google Drive installed (or Subversion) > you have already lost, because no slots are available anymore.
But there some way to make bigger Priority for your ShellExtensions. Read here more https://github.com/dwmkerr/sharpshell/issues/93

Related

How do you "Build" an exe that includes all the resource files like pics? Can exe be put on a web page?

I have students in high school who have created some programs using Visual Studio C#. They created some games and would like to now upload them to the web. I am pretty new to Visual Studio C#. I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on. It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place. How can I get a clean exe of their game? Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Microsoft wrote a guide on how to do exactly this. It's on their MSDN website, which is sort of like the developer back-bone for a lot of Microsoft software and documentation.
Old guide: Adding and Editing Resources (Visual C#)
Newer guide: How to: Add or Remove Resources
The gist is that the program needs to know where the files are, relative to the location of the compiled binary (in this case, an .EXE); There's several different ways to do this, depending on your level of expertise. I would suggest that you take a look at the guides above to start that journey.
there's a few ways of doing this. (Also, make sure you're creating a 'release' build when you compile).
You can include resources in your game by creating a resources file. This is something I usually do only on winforms applications etc.
If you have on-disk files you need to distribute those on-disk files along side your game. You could do this by zipping up your game.exe and the /files/images.img folder (or what ever your resources content folder is named).
If you're feeling adventurous you could create a 'deployment project' which is a project that allows you to create an installer file. This is a bit more work however you will have fine grained control over what files go where etc.
Good luck!
EXE files generally aren't self contained for video games with many resources, just add resources in an external folder and make sure the paths to the resources in their games are not absolute but relative in the local directory.
So for example:
get rid of paths like C:/Users/Bob/Desktop/Game/Images/player.png and replace with /Images/Player.png.
Also, an EXE generally doesn't run client side on webpages, it is possible but difficult. Things such as Flash are made for this sort of issue. I'd say make the webpage a place where they can download their games. Github has a nice way to do free websites called gh-pages. OFC, you could host one yourself but that would require a lot of setup work.
Like Monza said, you can zip up the files for download. Or, you could create an installer if you wanted to be really ambitious.
I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on.
That is correct, given that the other machine has the necessary .NET framework version installed AND any other resources like .dll files and config files are also present. When the application is ready for release, you can set the Build options in the project properties to Release, and then when you build all the files needed for distribution will be in the bin\Release folder.
It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place.
This may depend on how the application was written. If resources like pictures are embedded in the assembly then those files will not be needed to run on another machine. If the application is using hard coded paths for the image resources in the source code, then the application will likely break if the necessary files aren't present when the .exe is executed.
Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Yes - you could upload the .exe to a file server to make available for a download, but you would not be able to run it within a browser over the web. I would recommend zipping up the .exe and other files needed and hosting the .zip file on the web server for download; browsers may give a warning or block downloading an .exe .
Hope this explains it a little bit for you.

Creating a "portable" .exe (without installer)

I've recently coded a little program to determine numbers in a picture and it is reliant on two libraries I've used. (DLLs)
Since my target computer is not allowed to install programs due to security reasons, I need to create a portable .exe.
.NET is installed on the target computer but for some reason VS still does not include the libraries I've used in the exe but instead creates an application folder with a setup.exe, some .DEPLOY files and an application manifest.
I am new to VS and .NET in general so this question could be easy to answer, but I'm asking since I've found nothing useful on StackOverflow neither on google.
You can simply build the application and copy your bin/Debug folder along, but that would still mean you need multiple files.
In order to merge all references into the executable, use ILMerge. Here is some help calling ILMerge.
Basically, after building, you should do something like this:
ilmerge /target:winexe /out:SelfContainedProgram.exe
Program.exe ClassLibrary1.dll ClassLibrary2.dll
There is just one file you need to send along.
One way to do this is to build your application in Release mode (You can pick from Debug or Release in the drop-down). Then go to C:\Projects\[ProjectName]\[ProjectName]\bin\Release (The location of your project folder may vary). You'll see a bunch of files but all you really need are the DLLs, executable, and the config if you used one. You won't have to do any setup if you keep the necessary files in the application's folder, just copy them all to a folder on the target computer, create a shortcut if you want then you're good to go.
You can just copy all your assemblies into any folder you want. Simply chose "Build" from within Visual Studio and copy the files from bin/debug to your destination-folder.
However you have to ensure that all (relative) paths (if existing) still work as you cannot be sure where the user of your program copies the files to.
One simple way could be to use 7zip Packager, it doesn't need any installer. However, VisualStudio method might be more reliable.
I encountered the same issue recently. ILMerge suggestion above is no longer supported. I found Fody.Costura as a modern replacement.

How do I create and use a symbol server?

I created a powershell script that gets all the pdb files from the drop location after the build is set to release and copies them to a folder that is shared on the network.
I also created a sample application and I added the nuget packages that contain the assemblies that I need (without the pdb files).
I found some references on the net, but I was unable to debug my assemblies using the pdb files. I am using a VPN connection to connect to the shared folder that contains the pdb files and Visual Studio 2010.
What are the exact steps that I need to make in order to use the pdb files that are shared on the network to be able to debug the assemblies that I get using nuget package manager?
Thanks !
If you are looking for a good overview of symbols, Symbol Server, and more importantly Source Server indexing, check out http://bit.ly/SymbolServerTFS which is a blog post I wrote a while back talking about all of them. I specifically talked about it in terms of using Team Foundation Server but it's good information even if you aren't using TFS.
Also, if you want to make this experience better, please vote for my feature request on Uservoice: http://bit.ly/AtLSjl We definitely would appreciate the added voices & votes!
You could try, as a simple solution, VS/Tools/Options/Debugging/Symbols - and try set your symbols cache to your network share (haven't tried this before but might work, map drive etc. if needed).
At least that could get you running temporarily - and make sure you have automatically load for 'all modules' or specify yours.
hope this helps some.
Just define it at Options->Debugging->Symbols->Symbol file (.pdb) locations
Detailed instructions on MSDN

Open Office assembly folder

I googled "Open Office C#" and found a commonly reoccurring tutorial: http://www.opendocument4all.com/download/OpenOffice.net.pdf
The trouble is this portion (snippet from pdf):
Change from the Visual Studio window to a Explorer window. Move to the
CLI assemblies folder. You will find them in your OpenOffice program
installation path in the folder named “assembly”. In this folder you
should see the following .net assemblies.
I do not have this "assembly" folder. I navigated to:
C:\Program Files (x86)\OpenOffice.org 3
It simply is not there. I have to create reports using C#.
As per comments above from the OP the goal is to create DOC or DOCX:
For creating DOCX there is a FREE option (OpenXML from MS) available...
For creating the older DOC format (among lots of other things there is for example Aspose.Words (commercial - just a happy customer, not affilliated).
EDIT - as per comment:
All above options work independently of Word (i.e. don't need Office present/installed on the machine).
I'm not sure Yahia understood what you were asking...
As, I had the same issue (I think), I thought I would share the solution I found:
In version(s) 3.x+ the cli_* dlls are placed in the GAC and (afak) inaccessible from a VisualStudio project. You have to extract them from the openofficeorg1.cab file (using RAR, WinZip, 7z, whatever).
Here is a link that goes into more detail covering the topic:
http://blog.nkadesign.com/2008/net-working-with-openoffice-3/
BTW, when I did this (successfully), I found 6 such cli_* dlls.
It's worth mentioning that when I came across this tidbit, I had already deleted the initial installation folder that was created during the setup, so I had to uninstal OpenOffice and then reinstall to get that folder back. After that it was easy.
Hope this was of some help.

What is the best way for on demand download and install of dlls in .NET?

We have an application that we wish to install just a basic shell for. As the users use it, it will download and install the necessary dlls for actions that need to take place (imagine a wizard application scenario with several possible paths). Currently, everything is installed for all possible paths through the shell app.
For about 3 months out of the year, the dlls used for the possible paths go through a high churn rate with updates, so we wish to start ensuring the users have the most recent version of these dlls. The idea is that after all their selections are made, we'd make a web check to see what dlls are required for their selection and check to make sure they have the most recent version of those files.
All of this we have a plan for on how to do it. The problem I'm fighting is what is the most appropriate way to "install" these files. ClickOnce is not an option...too much legacy stuff here. Our app is installed in "Program Files" which obviously has restrictions for writing random files into the program's install folder under Vista and later.
Right now I see the options as the following:
On install mark the install directory as writable for the "Everyone" group. I haven't actually tested to see if this would work yet, or if Vista does something different in this scenario.
Split the download portion out into a second app that we can have prompt for elevated privileges so that it can download and install these files.
I'm leaning towards the second option since that maintains the security aspect of the Program Files folder. Others in the group lean towards the first option because they just don't want to have to worry about things. Or is there some other option I'm missing?
The app is a .NET app, though it has some requirements of third party dlls that are not managed assemblies.
As long as the dlls you want to load are managed, there are several ways to do this.
One way is to designate an Environment.SpecialFolder path such as AppData and dynamically load assemblies into your appdomain from there. RssBandit does this for plugins, there is a special directory that loads dlls and searches for specific interface implementations, loads them into a temporary appdomain, and then calls them from the app. You could take this one step further by using an IoC library like ninject or structuremap.
you could also try MEF, the new extensibility framework coming out in C# 4.
Personally, I like what Firefox/xul apps do. It's a hybrid of your two proposed solutions, I suppose. They have an updater.exe that lives in the install directory. I assume that means that the install directory is made writable during install so that they can run the update application. However, having never deployed a application in this manner, I can't tell you how much of a headache (or not) it is.
An alternative which you haven't mentioned, and may not know about, is using the .Net download cache. When you attempt to load an assembly you can give it a code base to load from. If you set the codebase to a web url (i.e. http://mywebhost/mycoolapp/) .Net will download the assembly from that url if it's not found in the download cache. It will also grab the latest version of the assembly from the web url if there is one.
This approach can be a pain as you'll likely have to deal with CAS security issues if your app needs elevated permissions. However, it is nice not having to write code to download the latest versions of your assemblies for you. If you want more information, I can find some resources and give more detailed examples.
The way I handle it is to have an update.exe installed into program files next to the main .exe file.
Then, on app startup, I have the app download an xml file off of the web and save it in the App Data folder. This file contains the latest versions of the dlls and has a simple Filename, Version structure.
Run through the list of filenames and if you don't have the dll locally or you have an older version, then add the needed dll to an update list.
After you generate your update list. Fire off the Updater.exe with a command line list of the files to be updated. You don't have to write them to program files but I do. On Vista, my updater pops up the UAC prompt correctly (as it should to maintain Program Files' security).
The updater then downloads the files to Program Files and restarts the main app.
One problem with firing off the second app is that you have to give it a manifest with "AsAdministrator" set in it.
This isn't hard to do, but once the updater is done and retriggers the main app, it cannot start the main app with normal privileges. An exe running as administrator can only start other exe's as administrator also, even if "AsInvoker" is set in the manifest. I don't know why you can't restrict it back to normal rights...you can only elevate permissions for some reason...

Categories