I am very new to c#.I started c# today.I don't know execution environment of c# very well.
I can explain my question more by taking netbeans as example.
When we create JSP project in Netbeans then it creates web.xml by itself.
This file is needed to deploy the project.So if we want to create JSP program without using netbeans then we have to create web.xml by ourself.
So my question is does VS also create files by itself that are very neccessary to run C# program?
Thanks
Save to a hello.cs file:
class P { static void Main() { System.Console.WriteLine("Hello World"); } }
then from a command prompt in the folder of hello.cs do:
%Frameworkdir%\v4.0.30319\csc.exe hello.cs
If you haven't done errors, you have compiled your first program. You don't need Visual Studio to do it.
So, yes, Visual Studio clearly generates all the files needed to compile a simple program (even a complex one, if you direct it correctly), considering that a .cs file is in truth all you need.
What Visual Studio 2012 generates for a console program is:
a solution and a project file (that are used to organize your source code and remember references to libraries)
a configuration file, (not necessary, but Visual Studio 2012 adds it just to write that the program will run on .NET 4.5)
your source code program
another source code program (AssemblyInfo.cs) so you can add copyright/other metainformations to your exe.
some random files that Visual Studio uses as cache (the .suo files)
I assume you are speaking only of ASP.NET C# execution, since you mention web.xml for Java. There is a web.config that is probably very comparable to that, since I am not a Java developer I really do not know.
The web.config is actually XML and it contains things like connection string to the database, HTTP modules, HTTP handlers, custom application settings that go above and beyond what is part of the core .NET Framework.
The difference lies in that this is not a unit of deployment, like it sounds the web.xml is in Java, but rather web.config is a run-time explanation of settings that the web server (IIS) uses properly run the application.
Related
This question is a complement for the post How to change the output name of an executable built by Visual Studio.
After reading this post I did the following:
Firstly, I followed the answer for this post and I could define the executable file name successfully.
Now, I would like to know if instead of only define the name as "Demo.exe" as mentioned in the example post above, it would be possible to embed the version defined in AssemblyInformationalVersionAttribute or in AssemblyVersionAttribute in the built file, resulting in something like "Demo_v1.0.0.0.exe"?
I'm developing my application in C# WinForms, using Visual Studio Express 2017.
Why would you want to change the name of the executable? Whenever you try building a Setup for your application, you need to change the Setup to include the new file. And when you install an update, your Setup needs to know all versions of your executable in order to delete the old version. That's just not what you want to do.
If you want to keep all versions of the software for yourself, come up with a different solution, e.g. moving the executable into a folder which has the version number.
That said, I have done this for Setups, so customers can download different versions of the Setup. I did that using a commercial tool called Visual Build, but there are other build automation tools available. So, my answer is: set up a continuous integration / continuous delivery pipeline (CI/CD) and automate the step there, not in Visual Studio.
From the project properties, you can add Post build event command line to rename your exe
pseudo
Maybe you can create another console renamer.exe which reads version defined in AssemblyInformationalVersionAttribute or in AssemblyVersionAttribute of your app and renames it and then call that renamer.exe from Post build event command line
write a powershell script to rename the newly built exe and call that script from Post build event command line
I want to run a utility (mt.exe) as a post-build step in a C# project. There is an environment variable/macro defined as DevEnvDir accessed by $(DevEnvDir). However, mt.exe is an SDK tool and not in the Visual Studio executable tree. Visual C++ projects have the WindowsSdkDir variable accessible by $(WindowsSdkDir). Ideally, I would want to have in my C# post build project a line that starts something like:
$(WindowsSdkDir)bin\x86\mt.exe .....
Is there anyway to add the WindowsSdkDir environment variable/macro to my C# environment?
I realize I could hard code the path, but I want something I can share between machines and developers.
I am new to C#.
I have a program that I want to work on any computer.
How do I compile the application to work on any computer without dependencies?
A simple hello world let's say:
class MainApp {
public static void Main() {
// Write text to the console.
Console.WriteLine("Hello");
}
}
In order to run a .Net application, you need the .Net Framework installed on that computer.
If this is a problem for you, pick another language.
To compile the application, you can either use Visual Studio and choose the Build Solution from the Build menu.
You can also use the command line and csc.exe
To compile your application via csc you will need to execute the following statement in the command prompt.
csc YourFile.cs
Any computer attempting to execute the assembly will need the .NET framework installed.
The other computer will need the ability to run .NET programs.
There are two ways that I know of that you can run your software on someone elses computer assuming they meet the above requirement.
The first way is to go into the bin folder and get the executable
(or the .exe file) this can just be distributed and ran. This is ussually in a path simular to this C:\Users\username\Documents\Visual Studio 2012\Projects\YourProjName\YourProjName\bin
The second way is to create a click once application. How to create a click once
On a side note, if you want your program to run on almost any machine I would choose a different language. Java is pretty popular and it is VERY close to C#. Many colleges focus on Java as well so it gives you a leg up if you ever go to school for it. That said, I did my whole degree in Java and ended up in a .NET shop so I had to relearn a ton of stuff.... On second thought, just learn everything...
I am having great difficulty getting a Windows program, written in VS 2008 C#, to launch another type program. I've put a main program to offer you the ability to launch some other VS 2008 C# programs. When one of them is selected the following code is intended to do the launch:
System.Diagnostics.Process.Start(#"C:\Documents and Settings\rat\My Documents\Visual Studio 2008\Projects\PV_002_082708\PV_001\PV_001\bin\Debug\PV.exe");
It works, but each user will have a different path. The path shown is for my computer. The code would have to know where each persons program was installed! In the past, I could easily call a program that was in the C:\Program Files location because that's where the MS Package & Deployment program put the programs. VS 2008/2010 doesn't put them there!
I'm sure I am not knowledgeable about Visual Studio 2008/2010 to know if there is a way around this, so any help would be greatly appreciated.
System.Diagnostics.Process.Start(System.Io.Path.Combine(System.Windows.Forms.Application.StartupPath, "PV.exe"));
assuming that the program is in the launched application's path.
or...
System.Diagnostics.Process.Start(System.Io.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), #"Visual Studio 2008\Projects\PV_002_082708\PV_001\PV_001\bin\Debug\PV.exe"));
assuming you want to open the project from it's place.
Once you create the installation package you can set the install path to some fixed path that users will not be able to change and than use that from your code (not very user friendly but it would work) or insert the user chosen path value into the registry and get it from there instead.
May want to have a look at this thread. How-to as well as lots of pro's and cons.
Embedded a *.exe into a dll
If you see the first answer to his question, I think this would work for you.
Simply he is saying, you add a resource file to your project, then when the user runes your program, it extracts your exe file that you added as a resource file to somewhere you know on the end users maching.
Every time I build my .NET application with Visual Studio, I got a appname.vchost.exe file along with my appname.exe file. This file doesn't exist when I build with command line commands. So,
What is this *.vchost.exe file for?
Could someone explain its working mechanism in detail?
Thanks.
I assume you're talking about the VS hosting process. It is used for
Improved Debugging Performance
Partial Trust Debugging
Design-Time Expression Evaluation
You can turn it off in the project settings. If you want to change the project settings template once and for all please see this question.
Its a version of the application used by visual studio to allow you to debug your application, if you clean your solution and build in release mode it will not be there.
Cheers