3

Software written in Visual Basic requires the .NET framework to be installed on the end-user's computer to be able to run. The is a large software framework that a user will probably not have on their computer. How can I distribute my VB.NET app with a .NET framework so that it can run properly on a user's machine?

When I try to create my deployment / installer you would think that it would automatically include a .NET 4.0 setup for the end-user, it does not. When I go through Microsoft Documentation like this: How to: Install Prerequisites with a ClickOnce Application all I get is something I've already tried and does not work. I have tried creating all sorts of installers which install the Microsoft .NET folder onto the end-user's machine, or the actual .NET executable file. None of these seem to work, even in third party installation creators like InnoSetup.

I need everything in one large setup.exe file. I don't care if it is going to take up a lot of space, as long as it is in one file and everything is embedded together (to make it easy for the user).

How do I package the .NET 4.0 framework and make it install with my VB.NET application in ONE Setup.exe file? If this isn't possible, where can I find the Actual Files of the .NET 4 Framework?

5
  • ClickOnce deployed apps can't make machine config changes. Oct 29, 2011 at 0:41
  • 2
    If your heart isn't set on ClickOnce, you might take a look at NSIS. I wrote an installer with NSIS which detects and downloads/installs .NET if necessary, with a little help from here... stackoverflow.com/questions/632587/… Oct 29, 2011 at 0:45
  • Are you wanting all the files in one large setup file?
    – Mark Hall
    Oct 29, 2011 at 1:09
  • @Mark Yes tht is exactly what I want to do Oct 29, 2011 at 1:37
  • It is possible with NSIS, only not with ClickOnce. I have not personally done it, but have installed applications that have the .Net framework 3.5 and SqlServer Express 2008 embedded in the Setup.exe file which is quite large, over 550 meg in size.
    – Mark Hall
    Oct 29, 2011 at 1:59

2 Answers 2

5

You need to add the appropriate prerequisite. Here is a link to the appropriate MSDN documentation: How to: Install Prerequisites with a ClickOnce Application

1
  • I have done all of this correctly, and every time I test it on another machine all I get is an error telling me to contact the software vendor. .NET 4 is not installed. Oct 29, 2011 at 1:21
2

I have used InnoSetup to determine if the .NET runtime is installed, and if not, download and install it automatically. I found that code on their website. This code is not tested, but should give you a good indication of what needs to be done.

[Files]
Source: "C:\SourceDirectory\dotNetFx40_Client_x86_x64.exe"; DestDir: "{src}"; 

The above code will include the .NET 4.0 client runtime as a part of the installer.

[Code]
function IsDotNetDetected(version: string; service: cardinal): boolean;
// Indicates whether the specified version and service pack of the .NET Framework is installed.
//
// version -- Specify one of these strings for the required .NET Framework version:
//    'v1.1.4322'     .NET Framework 1.1
//    'v2.0.50727'    .NET Framework 2.0
//    'v3.0'          .NET Framework 3.0
//    'v3.5'          .NET Framework 3.5
//    'v4\Client'     .NET Framework 4.0 Client Profile
//    'v4\Full'       .NET Framework 4.0 Full Installation
//
// service -- Specify any non-negative integer for the required service pack level:
//    0               No service packs required
//    1, 2, etc.      Service pack 1, 2, etc. required
var
    key: string;
    install, serviceCount: cardinal;
    success: boolean;
begin
    key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
    // .NET 3.0 uses value InstallSuccess in subkey Setup
    if Pos('v3.0', version) = 1 then begin
        success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
    end else begin
        success := RegQueryDWordValue(HKLM, key, 'Install', install);
    end;
    // .NET 4.0 uses value Servicing instead of SP
    if Pos('v4', version) = 1 then begin
        success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
    end else begin
        success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
    end;
    result := success and (install = 1) and (serviceCount >= service);
end;

function InitializeSetup(): Boolean;
var
    ResultCode: Integer;
begin
    if not IsDotNetDetected('v4\Client', 0) then begin
        Exec(ExpandConstant('{src}\dotNetFx40_Client_x86_x64.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
        result := (ResultCode == 0);
    end else
        result := true;
end;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.