I've created an application which is connected to database and I want to have Installer which allows me to run my app on other PC. I've tried publishing, creating Setup File in Visual Studio and Advanced Installer, but none of this options works. When i run it on my computer it works perfect. I know that i have to change connection string when i connect to database on other PC. I have SQL Server and .NET Framework on other PC too so it's not the problem. I searched and tried many solutions on the internet, please help me !
You can always include any type of file inside a Setup Project in Visual Studio. However, if you want to make a custom installer, you can easily do that.Here's some guidance that will help you greatly :
1.Create a zip
Search the term on google adding a c# tag at the end. You will find numerous answers even on SO on this. You can create a zip file and include every related file to your project in it. You can also simply add the database file in resource and access it.
2.Create the setup application
Create a WPF/WinForm project, design it the way you want. Now embed the earlier created zip file as a resource. Create a button to extract the zip file(do a quick google search of it too). You will now have a fully-customized installer
3.Take the installer to next step
What if there's already a version of your app installed on the client machine ? In your customized installer, make sure to create a registry key which will hold the path of where the installer will install the app(I mean where it will extract the .zip). Also add a check for the registry value. If there's a registry value, get the value which will be the path of the previously installed version, use the path to delete the folder/directory. Now do the rest of the work of step 2
The quickest way
Embed the database in your app as a resource.Now your setup project will automatically include it. However, the problem is that you cannot access the file directly from the resource as it has to be attached with a SQL Instance. However, you can use SqlLite for this.
Hope this helps :)
Related
As you could guess, I'm an absolute beginner to Visual Studios and C# Windows Forms (.NET Framework). I want to transfer my project from my laptop to my PC but I have no idea how to do so. I've been trying for quite a while but can't seem to get what files to copy. I'm copying the [Name].cs , [Name].Designer.cs and [Name].resx files but I can't seem to get them to work. should I copy the whole folder or .sln file or what?
Could anyone help me please?
Copy the whole root directory where the .sln is or .csproj if it is a single winforms project.
On the destination computer you might need some prerequisites.
If you want to be able to work on it and update it from both places, use GitHub and make a private repository. That's an easy way. The other way is follow the file path: C:\users\admin\source\repos and find your project in that list of folders. You could copy it to a flash drive, if you wanted to do it that way.
I just finished my simple C# desktop application. What I want to provide to my customer is an installer of the application(.exe). Also, I want the app to check for updates if ever I will do some updates without giving my customer the installer again.
I have read about the "ClickOnce" but I find it confusing especially the FTP part. Do I need to have an FTP server to upload the application files? Aside from that, most of the tutorials are deploying in the local machine (I guess).
Please advise me on this one.
You can use a tool like Advanced Installer. It is free and easy to use. But if you want to do automatic updates you can purchase a license for the professional version.
A direct quotation from MS documentation:
To specify a publishing location
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
In the Publish Location field, enter the publishing location by using one of the > following formats:
To publish to a file share or disk path, enter the path by using either a UNC path (\\Server\ApplicationName) or a file path (C:\Deploy\ApplicationName).
To publish to an FTP server, enter the path using the format ftp://ftp.microsoft.com/.
Note that text must be present in the Publishing Location box in order for the Browse (...) button to work.
For more information please check the following link.
Long story short, you can just use a publicly accessible file share on the intranet. Using an FTP server is just an alternative.
I'm creating a Windows Form application that is going to be used as a sign in system at my college. I was given a .csv file that includes student id numbers, names, teachers, and current courses. I have the app created and it works when I use it on my computer. However, when I publish the application and install it on a different computer, the streamReader that I use to access the .csv file is not able to use the .csv file because it's nowhere in the published application. I have tried adding the file to the root directory of the project, but I can't find out how to access it from there. I've read a few forums that talk about adding the file as a "resource," but I don't know enough about that to make it work for what I'm doing. Any assistance would be appreciated. Thanks!
In visual studio, add the file to your project (Add Existing after right click on the project). You'll need to add a build action as well, to tell the IDE to copy the file to the output directory. To do that, right click on the file you added, go to Properties, and look for BuildAction.
I have deployed an app that downloads from a web server. This is a normal desktop app installed using a msi produced by Visual Studio setup project. The address of the server is stored in app.exe.config as an application setting. Later, I change the address in app.exe.config using notepad, but the app is still using the old web address. In fact, I tried deleting the app.exe.config and the app still managed to get the old web address?????
Can someone explain what is happening.
Sorry if it confused some people. The settings are managed using the C# project's properties -> Settings page. The project is called updatesdownloader and the actual file I edit is updatesdownloader.exe.config which is in the same folder as the exe.
The code I used to read the server address string is:
Server updateServer = new Server(new Uri(UpdatesDownloader.Properties.Settings.Default.Server));
Where is the file that you are changing? Is the setting a user setting or an application setting?
You may want to look for your settings in the %AppData% or %ProgramData% folders on the user's machines.
You need to us ConfigurationManager.RefreshSection for a custom section that contains your settings.
Check this for an example on how to create a custom section
Are you sure the address is not hard-coded in the app itself? I would be sure that if you made reference to a URL using ConfigurationManager.AppSettings["SomeUrl"]; and attempted to go there, it would fail if the file did not exist.
I've created a winforms appliction and i need to check if .NET4 installed on the machine before starting the application.
im using the "Publish" option, it works great BUT im looking for a way to define the temporary folder where all the application files will be extracted to
the current behaiver is that when im starting the files that the Publish created ,it extracting all my application to :
C:\Users\shacharsa\AppData\Local\Apps\2.0\057V8G8X.MXV\6482W7L5.25P\smar..tion_30394eeddffd8a96_0001.0000_5bb050675a14dcbe\Files
and i want it to extract them to c:\temp
thanks,
shachar.
You can't define the location, however a better solution to your problem is available. You should read up on the ClickOnce bootstrapper and using that to detect and install prerequisites.
You can't do that, it is part of how ClickOnce works, its security model will not allow for that to happen.