Nov 17, 2010 at 7:49 AM
Edited Nov 17, 2010 at 7:51 AM
facing an issue with the self extracting file,
on my own pc it works fine, o other pc's when trying to open this file i get this error message box:
".NET Framework Initialization Error
to run this application you first must install one of the following versions of the .NET Framework v4.0..."
my application is targeting the .NET 4.0 framework.
is there some workaround or a way to bundle the .Net framework with the installed if its not installed on the computer ?
here is my code
Protected Sub Download1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Download1.Click
Dim emptyCheckboxList As Boolean = False
Dim ItemsNum As Int32 = chklst.Items.Count()
Dim MyFileStream As FileStream
Dim FileSize As Long
Dim fp As StreamWriter
Using zip As New ZipFile()
For Each lstItem In chklst.Items
If lstItem.Selected = True Then
emptyCheckboxList = True
zip.AddFile(Server.MapPath(".\files\") & lstItem.ToString, "")
' save self extracting file to server
zip.SaveSelfExtractor(Server.MapPath(".\files\temp\") & exeFileName, SelfExtractorFlavor.ConsoleApplication)
MyFileStream = New FileStream(Server.MapPath(".\files\temp\") & exeFileName, FileMode.Open)
FileSize = MyFileStream.Length
Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
Response.ContentType = "application/exe"
Response.AddHeader("Content-Disposition", "attachment; filename=" & exeFileName)
Using fs as New Filestream(Server.MapPath(".\files\temp\") & exeFileName, FileMode.OpenOrCreate, FileAccess.Read)
Dim Buffer2(2048) as Byte Dim n as Int32
Do n = fs.Read(Buffer2, 0, 2048)
Response.OutputStream.Write(Buffer2, 0, n)
Loop While n > 0
If emptyCheckboxList = False Then
ErrorLbl.Text = "No File was chosen for download, please select files "
ErrorLbl.Text = "" End If
Catch ex As Exception
ErrorLbl.Text = "Download_Click: " & ex.Message
Nov 17, 2010 at 10:18 AM
I had typed in a long detailed answer for your question, but my internet connection went down, and I lost it.
An SFX is a .NET application. As such it requires that the .NET Framework be present on the computer that runs the SFX. There is no way for a .NET application itself to guarantee that the requisite .NET Framework is available before running.
One approach to insuring that pre-requisites in general are available on a computer is to package the application into an MSI (Microsoft Installer). You can build one of these using a Setup and Deployment project in Visual Studio. In the project
you can stipulate the pre-requisites, including the .NET Framework runtime. An MSI offers other features as well: the user can choose an installation directory, can review and select optional features for the application, and can uninstall the application
later using MSI. This is probably the best way to distribute a custom .NET application that is beyond simplistic.
The MSI is not a good approach to distribute an SFX application. I said earlier that an SFX is just a .NET application. So why should the SFX be treated differently than other .NET Applications? It's this: the SFX is not intended to be run
repeatedly, and used over the long term. It's typically something you run once. As such, a better way to insure pre-requisites in this case is to tell the user to install the .NET Framework, perhaps by referring the user to a URL where the .NET Framework
can be downloaded, like http://www.microsoft.com/net/download.aspx .
A similar approach may be appropriate for deploying your application. If it's a fairly simple app, then just asking people to install .NET 4 with a URL click, might be the right approach.
Hi Cheeso, i guess this is the right approach.
thank you again for your quick responses.
Using Ionic.Zip v188.8.131.52 to create a self extracting zip.
The FAQ says "The self-extractors require .NET 2.0 on the computer doing the extraction".
When I try to run the self extrator on a machine that only has .Net 2.0 Service Pack 2,
I get a .Net Framework Initialization Error:
"To run this application, you first must install one of the following versions of the .Net Framework: v4.0.30319"
I understand the above answer to buzibuzi. so, I'm not ask HOW do I get 4.0 on a pc.
My question is; Am I missing something, or has the .Net Framework requirement changed?
Sep 28, 2011 at 4:24 AM
This is a bug in DotNetZip. I've already filed a workitem; need to implement the change and fix it.
Has this bug been fixed.