Wednesday, June 8, 2011

how to run c sharp on linux


How to Run C# on Linux OS
Here i am going to explane how to run C#(not GUI based ) on linux OS step wise .
1) Installation Process
a) Go to the following web site
http://go-mono.com/sources-stable/
b) dowanload mono-1.2.5.2.tar.bz2
c) go on terminal (command prompt for windows user )
d) login to root user
e) move mono-1.2.5.2.tar.bz2 to /usr/local/src by using following code
mv mono-1.2.5.2.tar.bz /usr/local/src
f) also move to src directory
cd /usr/local/src
g) type the following command to untar ( ie unzip for windows user ) the package
tar -xjf mono-1.2.5.2.tar.bz2
a new directory is created named " mono-1.2.5.2 "
h) move to that directory and type
./configure (dot then back forward slash )
after the configeratin will finish type
make
after make is created type
make install
All these process take 30 to 35 minute so be clam and coll till the process ends .
After make is installed we are now redy to run and execute c# programe .
2) Runing and Executing the C# programe
I follow the same old method of learning a programin language ie by writing the same old our Hello word program .

Learn how to register an assembly in the GAC.




1) Create an assembly key file

Use the sn.exe tool to create a key file:
sn -k StrongNameFile.snk

If your path environment variables aren't set, you'll have to go to the C:\Program Files\Microsoft.NET\FrameworkSDK\Bin\ directory to run sn.exe)
The filename "StrongNameFile.snk" can be any name you want.

2) Edit your assembly
Now you have to add a tag which will link your assembly key to the assembly:

using System.Reflection;
[assembly:AssemblyKeyFile("StrongNameFile.snk")]

Normally this is done in the utility AssemblyInfo.cs (vb) file.

3)Add your assembly to the GAC

gacutil /i AssemblyFileName.dll

To uninstall this assembly from the GAC, use the command:

gacutil /u AssemblyFileName

4) (Opional) Add your assembly to machine.config

Locate the <assemblies> tag (for web apps,under <configuration>/<system.web>/<compilation>/<compilers>/<assemblies>)
Between the <assemblies> tags, enter:

<add assembly="AssemblyFileName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=5edf592a9c40680c" />

Tuesday, June 7, 2011

How to create dll in c sharp

HowTo create a dynamically linked library (DLL) with C# (C-sharp) and
Visual Studio 2005.

HowTo create a dynamically linked library (DLL) with C# (C-sharp) and
Visual Studio 2005.

1. Creating the DLL:

a) Create a new project -> C# Classlibrary.

b) Create your class adding or modifying
a class-file to the project and entering
something like:

using System;
  using System.Collections.Generic;
  using System.Text;

  namespace MyClassLib
  {
      public class ClassA
      {
   public int PropA = 10;

   public void Multiply()
   {
       PropA *= 2;
   }

Monday, June 6, 2011

how computer networks works


how to get process in c#

using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
 /// <summary>
 /// Shell for the sample.
 /// </summary>
 class MyProcess
 {
 
   
 
  void BindToRunningProcesses()
  {
   // Get the current process.
   Process currentProcess = Process.GetCurrentProcess();
  
   // Get all instances of Notepad running on the local
   // computer.
   Process [] localByName = Process.GetProcessesByName("notepad");
  
   // Get all instances of Notepad running on the specifiec
   // computer.
   // 1. Using the computer alias (do not precede with "\\").
   Process [] remoteByName = Process.GetProcessesByName("notepad", "myComputer");
  
   // 2. Using an IP address to specify the machineName parameter.

how to write text into notepad file

 class WriteTextFile
    {
        static void Main()
        {
            // These examples assume a "C:\Users\Public\TestFolder" folder on your machine.
            // You can modify the path if necessary.
            // Example #1: Write an array of strings to a file.
            // Create a string array that consists of three lines.
            string[] lines = {"First line", "Second line", "Third line"};
            System.IO.File.WriteAllLines(@"C:\Users\Public\TestFolder\WriteLines.txt", lines);

            // Example #2: Write one string to a text file.
            string text = "A class is the most powerful data type in C#. Like structures, " +
      

Wednesday, June 1, 2011

Exporting Data to Excel

ASP.NET Tip: Exporting Data to Excel
A common request of users is to be able to download data for use in Microsoft Excel. This is actually fairly easy to accomplish without a lot of extra work. I do most of my database work with DataTable objects, as I don't need the overhead of a DataSet. I also have a Database wrapper class that is able to easily retrieve data from a SQL Server database. Once I use my function to get my DataTable, I can start exporting the data. For this example, however, I'll use the traditional SqlDataAdapter method to retrieve the data initially.
There are a few tricks to making this work. First, you have to create an ASPX page with no HTML content in it. The only thing that should be in the ASPX page is the Page directive at the top. The second trick is to clear the existing content and send down a new content type. For Excel, you use a content type of application/vnd.ms-excel. This tells your Web browser to expect something that can be handled within Excel. The third trick is to send down the data tab-delimited per column and a newline at the end of each row. After that, Excel does the rest of the work for you.
Here's the code:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("yourconnectionstring");
cn.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Users", cn);
DataTable dt = new DataTable();
da.Fill(dt);
cn.Close();

Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
string sep = "";
foreach (DataColumn dc in dt.Columns)
{
Response.Write(sep + dc.ColumnName);
sep = "\t";
}
Response.Write("\n");


AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...