Wednesday, October 27, 2010

how to debug remotely in Visual Studio 2008

On Server side:


the most important is that the compiled version should be in "Debug" mode because the released version doesnt have the debugging information.

you have to install the "Visual Studio 2008 Service Pack 1 Remote Debugger".

you can download "Visual Studio 2008 Service Pack 1 Remote Debugger" from here

once you have installed it, run the service with "Local Account" authentication. and then run the debugger "rdbgwiz.exe" and allow the users on the domian to connect to the debugger remotly.

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\rdbgwiz.exe

afterward run "MSVSSMON.EXE" as Administrator. otherwise you can not debug "w3wp.exe"

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe

On Developer side:



On Developer side where visual studio is intalled you need to open web Solution with visual studio 2008 and go to Menu debug and attach to debugger and then giving pc name and then connect to w3w.exe
You have to open the project otherwise the debug menu will not show up.


To attach to a running ASP.NET application, you have to know the name of the ASP.NET process:

If you are running IIS 6.0 or IIS 7.0, the name is w3wp.exe.

If you are running an earlier version of IIS, the name is aspnet_wp.exe.

For applications built by using Visual Studio 2005 or later versions, the ASP.NET code can reside on the file system and run under the test server WebDev.WebServer.exe. In that case, you must attach to WebDev.WebServer.exe instead of the ASP.NET process. This scenario applies only to local debugging.

Image handler for ASP.NET

there are two ways to return an image in asp.net as response , I tested both and the first 1 is much faster.

the first one is to use the Stream:


            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.yourwebsite.com/image.jpg");
            request.Timeout = 5000;
            request.ReadWriteTimeout = 20000;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            System.Drawing.Image img = System.Drawing.Image.FromStream(response.GetResponseStream());
            img.Save(Response.OutputStream, ImageFormat.Jpeg);
            img.Dispose();

the second one is to use binary:

        WebRequest request = WebRequest.Create("http://www.yoursite.com/image.jpg");
        request.Credentials = CredentialCache.DefaultCredentials;
        HttpWebResponse   resp = (HttpWebResponse)request.GetResponse();
        Stream dataStream = resp.GetResponseStream();
        Response.Clear();
        Response.ContentType = resp.ContentType;
        BinaryReader reader = new BinaryReader(dataStream);
        Response.BinaryWrite(reader.ReadBytes(Convert.ToInt32( resp.ContentLength)));
        Response.Flush();
        reader.Close();
        dataStream.Close();
        resp.Close();

and you can access the both by using
<img src="http://localhost/WebSite/yourpage.aspx" />

PS: you can also write a handler which return back the image as output Response:

<%@ WebHandler Language="C#" Class="Handler" %>


using System;
using System.Web;
public class Handler : IHttpHandler {
    public void ProcessRequest(HttpContext context)
    {
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(path);
            request.Timeout = 5000;
            request.ReadWriteTimeout = 20000;
            System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
            System.Drawing.Image img = System.Drawing.Image.FromStream(response.GetResponseStream());
            img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            img.Dispose();
    }
    public bool IsReusable {
        get {
            return true;
        }
    }
}

Wednesday, October 13, 2010

How to find your SQL server version

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

version 8 -> SQl 2000
version 9 -> SQl 2005
version 10 -> SQl 2008

when you connect through your MSSM (Microsoft Sql Server Management Studio) you can find your SQL version like following photo:

Tricks in skype

1. How to enable the file sending in Skype:


to enable the file sending in Skype:

go to registary ( cmd -> regedit )

http://hkey_local_machine/SOFTWARE/Policies/Skype/Phone

DisableFileTransfer = 0

2. Run another instance of Skype:

go to "C:\Program Files\Skype\Phone\Skype.exe" (where you installed skype)

right click on skype and create a shortcut on desktop

then right click on shortcut and add "/secondary"

"C:\Program Files\Skype\Phone\Skype.exe" /secondary

Monday, October 11, 2010

Virtual CD

Here I wanna introduce some Virtual CD

DAEMON Tools
the free version is called Deamon light which is available here

MagicISO Virtual CD/DVD-ROM
the advantage of MagicISO is that you dont need to restart windows after installation

Alcohol 120%
Alcohol 120%, is a powerful Windows CD and DVD burning software that makes it easy to create backups of DVDs and CDs.