In the announcement post for 4.0.17, I mentioned that there was a new “portable mode” and to “see blog/forum post for details.”
What does it do
1) This will move Paint.NET’s internal AppSettings (not to be confused with .NET’s idea of “appSettings”) to be stored in a JSON file called PaintDotNet.AppSettings.json. Since it’s JSON you can use any JSON tools to read, write, or process it. The location of this file is not currently configurable; it will always be in the same directory as PaintDotNet.exe.
Paint.NET’s internal AppSettings covesr things like the window positions and sizes, and any changes you make in Settings (e.g. Tool defaults), as well as the settings you use for saving files (e.g. JPEG quality).
2) The updater will not be enabled in this mode, and the UI for it will not be available in the Settings dialog.
3) At startup, Paint.NET checks to see if there are any missing files from the installation. If anything’s missing, it offers to run a repair. Since repair is done by reinstalling the MSI, and this isn’t possible in portable mode, this behavior is also disabled.
4) Effect plugins can actually query the install type/state via the IAppInfoService and the InstallType property. Use the GetService() method to do this. I’m not sure if this will be useful
How to enable it
You’ll have to modify the file PaintDotNet.exe.config. In general, I don’t recommend doing this, as there are some weird and scary settings in there which have been collected and fine-tuned over the years to craft just the right behavior for Paint.NET’s use of the .NET Runtime. But, this file is also capable of holding application-specific settings for some bizarre reason.
You’ll want to add a new setting called PaintDotNet.EnablePortableMode with a value of true in the <appSettings> section, toward the bottom of the file:
<?xml version="1.0"?>
<configuration>
<runtime>
<gcAllowVeryLargeObjects enabled="true"/>
<generatePublisherEvidence enabled="false"/>
<legacyCorruptedStateExceptionsPolicy enabled="true"/>
<loadFromRemoteSources enabled="true"/>
</runtime>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
<add key="PaintDotNet.EnablePortableMode" value="true" />
</appSettings>
</configuration>
How to get a “portable” copy of Paint.NET
With this addition, you should no longer need to go to a 3rd-party site to get a “portable” version of Paint.NET, although maybe they’ll still offer some added value that I’m not aware of, like also including a “portable” copy of the .NET Framework 4.6.
All you need to do is:
- Install Paint.NET on any system
- Copy the installation folder, which is usually C:\Program Files\paint.net, to a USB stick (or wherever)
- Enable “portable mode” as described above, by editing the .exe.config file
- Take the USB stick to any other PC that already has .NET Framework 4.6 installed, and then run PaintDotNet.exe
- Voilà! Now you have a portable copy of Paint.NET.
Conclusion
And there you go Paint.NET has already been capable of running “portable” with respect to its installation dependencies, other than .NET itself, due to changes in the Visual C++ runtime and Universal C Runtime deployment peculiarities. The ability to route the app settings to a local file, however, is a new addition, and will ensure that Paint.NET doesn’t feel like it’s been “reset” every time you run it on a new computer.