Compile and Run .NET program with just .NET framework on your system.

Compile and Run .NET program with just .NET framework on your system.

Did you know that every .NET framework installation also installs VB & C# compiler.

Using these compilers you can compile and run C# or VB.NET program on machine with just .NET framework installed. This can be useful on system where installing full visual studio is not an option.

Here is how to do it

If .NET framework installed on you system, C:\Windows\Microsoft.NET\Framework directory  should list all the versions. Here is what is on my machine.

image

Once you find required .NET version, directory content should list csc.exe and vbs.exe compiler executable. As shown below.

image

Now use C# or VB compiler to compile the program as follows. For example use .NET 2.0 compiler to generate .exe c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe Program.cs

image

Advertisements

Simple way to share files from between Linux to windows

I often use both Windows and Linux environment at work. Sometimes I need to share files between Linux & windows workstation.

There are couples of ways to share files between Linux & Windows.

  1. Setup Samba server (CIFS share) on your Linux box, which can be accessed from any windows machine. Because In many of the Linux distros Samba server is not installed by default. It requires installing package and setting up configuration file to share folder.
  2. Run Ftp server on you Linux box and use ftp client from windows box to access it. Again this solution may require starting the ftp server on the Linux machine and configuring it to allow access to shares.
  3. Run SSH server on Linux machine and on windows box you use secure copy(scp) or similar SSH client to do file transfer. You can download scp client for windows putty download page.This also requires installing SSH server on Linux box ( for Ubuntu by default SSH server is not installed)

Even though many of the option listed are simple , it requires some effort to setup. You need to repeat the same when you re-install Linux.

Recently I discovered simple and elegant way to achive the same using python built in SimpleHTTPServer module.Advantage of this approach is python is by default installed on all Linux distributions. No need to install any additional package.

Here is how to do it

    1. From the command shell, go to the directory you want to share. For example if you want to share “/usr/home/john/files” .                                                                                                                                                                       $ cd /usr/home/john/files
    2. Run following command to share files. This command starts the webserver on port 8080 with directory browsing enabled .                                                                                                                                                                             $ python -m SimpleHTTPServer 8080
    3. On your windows box point your any Webrowser to http://<linux_machine_ip&gt;:8080 . This will list all the files present on the Linux box . Now select any files download to windows.

Resource