31. December 2012
Everyone who worked with ClickOnce to publish his software knows about the big issue that proxy authentication is not supported by Microsoft and you just get a nasty error message like this:
The remote server returned an error: (407) Proxy Authentication Required.
Matt Davis wrote a blog post back in 2009 how developer can bypass this issue when downloading updates.
However, this is only possible after the software was deployed on the target machine, e.g. it is necessary to create a offline setup and set it to the customer.
To solve this issue I created a loader that replace the original "dfsvc.exe" of the .NET Framework and set a custom web proxy like described in the post by Matt Davis and then invokes the internal entry point (named "System.Deployment.Application.DFServiceEntryPoint.Initialize").
The source code is available here on GitHub.
This project has two build configuration, "netfx2-Release" and "netfx4-Release" which will build a .NET 2.0 and 4.0 version of "dfsvc.exe" and copy it inside the "Build" directory of the solution.
Also there is a "ClickOnceProxySettings.xml" file where you have to configure your proxy credentials.
So how do you use this?
- Download ClickOnceWithProxySupport_v0.1.zip (8.88 kb)
- Extract the "Build" directory
- Open "ClickOnceProxySettings.xml" with Notepad and set your credentials
- Inside the Windows Explorer, navigate to "%windir%\Microsoft.NET"
- Copy the "ClickOnceProxySettings.xml" inside this directory
- Depending if you have a 32 or 64 bit installation you have two sub directories: "Framework" and "Framework64" (on x64 only).
Inside this directories you have a folder "v2.0.50727" and/or "v4.0.30319" (also depend on which framework versions you have installed).
- Now you have to copy in each directory the right version of the "dfsvc.exe" from the "Build" directory, just look at the table below:
Make sure that there is currently no instance of "dfsvc.exe" running (check taskmanager)
- That's it, you should now be able to run ClickOnce based online installations thought a proxy server with authentication