Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I bundle the VC++ 2015 redistributable with my ClickOnce (.NET) application?

I have a C# application running on the .NET Framework 4.5 deployed via Microsoft ClickOnce. I also am utilizing a small utility from a Microsoft SDK called DComPerm.exe which is a C++ application that I had to compile separately. My main application uses Process.Start() to access this executable.

When I first tried running this on a client machine, I got an error message stating that VCRUNTIME140.dll was missing when the application tried to call DComPerm.exe.

VCRUNTIME140.dll missing

This makes sense... since that program was compiled in C++ it needs the Visual C++ 2015 Redistributable package, which had not been installed on the client machine. I want to make this as painless as possible, so I was hoping I could bundle the VC++ 2015 Redist with my ClickOnce application. Under the project properties > Publish tab, there's a button for Prerequisites, which allows me to specify that the application should bundle the redistributable package.

Prerequisites on Publish tab

That sounds great in theory, but it doesn't work. Now when I try to install my ClickOnce application on the client machine, it doesn't work. The installation fails and points me to a log file, which contains the following relevant information:

'Visual C++ "14" Runtime Libraries (x86)' RunCheck result: Install Needed

Installation of components 'Visual C++ "14" Runtime Libraries (x86)' was accepted.

Copying files to temporary directory "C:\Users\Owner\AppData\Local\Temp\VSD3872.tmp\"

Downloading files to "C:\Users\Owner\AppData\Local\Temp\VSD3872.tmp\"

(8/4/2016 12:57:48 PM) Downloading 'vcredist_x86\vcredist_x86.exe' from 'http://go.microsoft.com/fwlink/?LinkID=800028&clcid=0x409' to 'C:\Users\Owner\AppData\Local\Temp\VSD3872.tmp\'

Download completed at 8/4/2016 12:57:49 PM

Downloading failed with HRESULT=-2146697208

And that message makes it pretty clear what the problem is: the link that it's trying to use to download the redist package is dead. Only... I'm not sure how I can tell it to find the correct link. I'm quite surprised that it can't find it automagically as that seems like a bug with Visual Studio. Some searching revealed that the correct link is actually this one, but that's not what ClickOnce is resolving. I also saw that by checking the box this was the corresponding XML update to my csproj file:

<BootstrapperPackage Include="Microsoft.Visual.C++.14.0.x86">
  <Visible>False</Visible>
  <ProductName>Visual C++ "14" Runtime Libraries %28x86%29</ProductName>
  <Install>true</Install>
</BootstrapperPackage>

Is there some XML tag I can use to specify the location explicitly? Or how else can I fix this? How can I bundle the redistributable without breaking my application?

like image 939
soapergem Avatar asked Aug 04 '16 19:08

soapergem


People also ask

How do I install Microsoft Visual C++ redistributable packages?

The Redistributable is available in the my.visualstudio.com Downloads section as Visual C++ Redistributable for Visual Studio 2019 - Version 16.7. Use the Search box to find this version. To download the files, select the platform and language you need, and then choose the Download button.

Do I need all Microsoft Visual C++ redistributable versions?

We don't recommend that you delete any Visual C++ redistributable, because doing so could make multiple applications on your computer stop working. Given how little space they take up and how broadly they are used, it doesn't seem worth the hassle to mess with your current ecosystem of standard library files.

How do I install a ClickOnce application?

Install ClickOnce applications After it is deployed to the deployment location, end users can download and install the application by clicking an icon representing the deployment manifest file on a Web page or in a folder.


1 Answers

I had pretty much the exact same problem. You asked how to specify the download location that ClickOnce resolves. In order to do that, open

C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages\vcredist_x86\en\package.xml

and edit the attribute with Name="https://go.microsoft.com/fwlink/..." to the correct URL. By the way, thanks for finding the correct download link, I hadn't been able to find it until seeing this post.

The VC++ Redis installed correctly on the client's computer after doing this.

like image 61
Dillon Avatar answered Sep 22 '22 15:09

Dillon