Click here to Skip to main content
15,887,214 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Standalone .NET framework exe Pin
Dave Kreskowiak21-Jul-13 6:03
mveDave Kreskowiak21-Jul-13 6:03 
GeneralRe: Standalone .NET framework exe Pin
LostTime7621-Jul-13 6:09
LostTime7621-Jul-13 6:09 
GeneralRe: Standalone .NET framework exe Pin
Dave Kreskowiak21-Jul-13 10:57
mveDave Kreskowiak21-Jul-13 10:57 
GeneralRe: Standalone .NET framework exe Pin
LostTime7621-Jul-13 13:32
LostTime7621-Jul-13 13:32 
GeneralRe: Standalone .NET framework exe Pin
Dave Kreskowiak21-Jul-13 14:53
mveDave Kreskowiak21-Jul-13 14:53 
GeneralRe: Standalone .NET framework exe Pin
LostTime7621-Jul-13 15:05
LostTime7621-Jul-13 15:05 
GeneralRe: Standalone .NET framework exe Pin
Dave Kreskowiak22-Jul-13 1:50
mveDave Kreskowiak22-Jul-13 1:50 
GeneralRe: Standalone .NET framework exe Pin
LostTime764-Aug-13 9:22
LostTime764-Aug-13 9:22 
In case anyone is interested on the status of my topic. After several more days of probing, I have successfully been able to run a WPF application by unpacking a much smaller .NET distributable compared to having to install the entire framework. My app is simplistic, and just is a WPF window with a button inside that when clicked shows a messagebox. I wanted to just get this working and test the theory. I have packed all the necessary files: registry entries, .NET framework folder, and my simple WPF app into a file. After purging the .NET framework folder of everything unneeded (dll, install files, configuration files), the resulting distributable folder is 48.1MB. Using 7z to pack this results in a file that is 12MB. This includes system.dll, PresentationFramework.dll, PresentationCore.dll, System.xaml, and system.xml managed assemblies. Also, using the method I have devised, you can unpack this distributable file to any location and run the application from there. This will come in handy when I elaborate on the end goal in the next sections.

So let me take a step back and explain why I did this. Here is the scenario. We want to deploy our application to manufacturing; however, the computers that are being used are running a minimum of XP. This means that we have to plan for no .NET framework install on the system. Keep in mind that the people running our application don't understand anything about installs, etc., therefore we have to make it a click once solution. The most that they know how to do is download a file from the internet, copy it to a flash drive and run it on the computer.

With this in mind, we of course can say to them: hey, install the .NET framework first then use our program. This introduces another step for them. Believe me when I say introducing steps into this system is a bad idea. These people are computer illiterate and do not have the time to be tracking down files and installs. The less stuff you have in the system the better. We also have the goal of having a custom branded UI the entire way. Lastly, we want to run a few custom program / build steps before we actually install our program to verify certain things on the computer beforehand. In the end, we will install the .NET framework 4 if it is on the computer, BUT, we also want this entire process to be inline with our custom branding. Thus we cannot run the .NET installer as is. Luckily, the .NET installer allows us to install silently and also pipe progress to our program via a memory map. Also, keep in mind that the .NET installer will take several tens of seconds to fully install on the system.

So.. here is the series of events that will happen: User downloads our click once file and runs it on their computer. We get and create a temporary directory. If .NET is not installed on the system, we unpack our .NET redistributable. We then unpack our custom WPF app. Additionally, a standalone version of 7zip is unpacked to the directory so that we can unpack stuff. In order to run the WPF app without .NET, we need to install some registry keys. They get installed. Next, our WPF app is started. It then deletes the registry keys that it installed. Since the WPF app is already started, it can do this, because the registry is not needed anymore. The user then presses next to install our real application. During this process, since .NET is not installed, we unpack the .NET installer and pipe the progress to our WPF app and install the framework.

With this method, the .NET installer has no knowledge that we are in fact running a WPF app without the framework installed, because the registry keys used are already cleaned up, and we are running the framework from a temp directory. Of course, the above method is watered down, but if anybody is interested in specifics, I can explain further.

Now, the reason it took so long to figure this out was because I was missing a piece of the puzzle. It turns out that the .NET framework uses TWO important registry nodes to get directory information. This is how you can run the framework from a directory outside of C:\Windows\.NET.... etc.. The two important nodes are HKLM.....software\microsoft\.NETFramework AND HKLM...software\.NETFrameworkSetup... and all associated keys. There are I think 4 path keys that point to directories for the framework. If you redirect them all, to your custom framework folder, you can run the framework from the custom directory.

Next, there are a few more things we have to realize. The framework needs a set of native dlls to run that are installed with the framework into the system32 folder. I believe we can also reroute these dlls into our custom .NET folder and have it work. As I write this, I kick myself for forgetting to test that aspect out. Anyhow, the important dlls are mscoree.dll, mscoreei.dll, mscoreeis.dll, msvcxxx_xxxclr.dll. I don't know the exact list off the top of my head, but as long as you have these in a path that can be found by distributable, it will run fine. These dlls are unpacked with the .NET framework and are not shipped with a bare install of XP. Windows 7 might already have some of these dlls due to .NET already being installed. In addition to the above dlls, you need to also put mscorwks.dll into the .NET distributable framework folder.

Lastly, it turns out that if the clr cannot find the managed assembly that it needs, it actually falls back to looking in the directory where you started the original exe from. The clr uses the registry to determine locations of assemblies, such as the GAC assemblies. I couldn't be bothered to track down these keys or figure out how they worked and solely relied on the fact that the clr will look at the directory you started the exe in. Therefore any assembly you need for the program can safely be packed in the same directory as the program itself and be found. When I was testing, the clr tried to look for GAC assemblies using the registry, and of course they were not in the registry, because I tested my method by uninstalling the framework first.

So overall, this entire process should take around 3 - 5 seconds to execute on a slow XP machine without the .NET framework. So within that time you can copy the files, modify the registry and execute a WPF program without installing the framework. If anybody is actually interested in more detail, drop a line.
GeneralRe: Standalone .NET framework exe Pin
Pete O'Hanlon4-Aug-13 9:51
mvePete O'Hanlon4-Aug-13 9:51 
GeneralRe: Standalone .NET framework exe Pin
LostTime764-Aug-13 10:19
LostTime764-Aug-13 10:19 
GeneralRe: Standalone .NET framework exe Pin
Dave Kreskowiak20-Jul-13 9:47
mveDave Kreskowiak20-Jul-13 9:47 
GeneralRe: Standalone .NET framework exe Pin
LostTime7620-Jul-13 10:30
LostTime7620-Jul-13 10:30 
GeneralRe: Standalone .NET framework exe Pin
Dave Kreskowiak20-Jul-13 10:38
mveDave Kreskowiak20-Jul-13 10:38 
GeneralRe: Standalone .NET framework exe Pin
LostTime7620-Jul-13 11:01
LostTime7620-Jul-13 11:01 
AnswerRe: Standalone .NET framework exe Pin
Eddy Vluggen20-Jul-13 23:36
professionalEddy Vluggen20-Jul-13 23:36 
AnswerRe: Standalone .NET framework exe Pin
jschell21-Jul-13 9:50
jschell21-Jul-13 9:50 
GeneralRe: Standalone .NET framework exe Pin
LostTime7621-Jul-13 14:12
LostTime7621-Jul-13 14:12 
QuestionInvoke from MASM Assembly Language Pin
Derek Tortonian16-Jul-13 7:57
Derek Tortonian16-Jul-13 7:57 
AnswerRe: Invoke from MASM Assembly Language Pin
Pete O'Hanlon16-Jul-13 8:38
mvePete O'Hanlon16-Jul-13 8:38 
GeneralRe: Invoke from MASM Assembly Language Pin
Derek Tortonian17-Jul-13 7:14
Derek Tortonian17-Jul-13 7:14 
GeneralRe: Invoke from MASM Assembly Language Pin
Dave Kreskowiak17-Jul-13 7:26
mveDave Kreskowiak17-Jul-13 7:26 
GeneralRe: Invoke from MASM Assembly Language Pin
Derek Tortonian17-Jul-13 7:28
Derek Tortonian17-Jul-13 7:28 
GeneralRe: Invoke from MASM Assembly Language Pin
MicroVirus17-Jul-13 11:24
MicroVirus17-Jul-13 11:24 
QuestionMysql query with date conditions not working in server Pin
ven75312-Jul-13 4:10
ven75312-Jul-13 4:10 
AnswerRe: Mysql query with date conditions not working in server Pin
NotPolitcallyCorrect12-Jul-13 4:52
NotPolitcallyCorrect12-Jul-13 4:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.