Most of time when we want to run Visual Studio 2010 as Administrator role, we can right click the Visual Studio short cut in start menu and choose “Run as administrator”;

Sometimes if you forgot to choose “Run as administrator” and open a project which need administrator permission, you have to restart Visual Studio. So is it possible that we just click Visual Studio short cut icon to run with administrator automatically ?

The answer is Yes and Simple !

In Windows 7, we can do all executable program like the following steps to let them run as administrator automatically:

If you are using Windows 7 or Windows Vista, or Windows Server 2008, you should know the UAC (User Account Control), this is one of significant differences between Windows XP and the newer Windows System.

“User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. When you attempt to perform a task that requires administrative privileges, you can dynamically elevate your role by using the Consent dialog box. The code that executes the IsInRole method does not display the Consent dialog box. The code returns false if you are in the standard user role or in the Built-in Administrators group. You can elevate your privileges before you execute the code by right-clicking the application icon and indicating that you want to run as an administrator.” – From MSDN.

When you build a Windows Form application using C#, your application will not run as administrator by default. Then if your application need more permissions just like an Administrator, you might get problem since your application can not access enough resources;

The simplest solution is disabling the UAC on your Windows system. About how to disable UAC, we will discuss in another time, this time we do not want to talk about more about this since disabling UAC for a windows system is not recommended.

The normal and the best solution is using manifest file.

Open your application in Visual Studio 2010, Right click the project and add a new item, choose “Application Manifest File”:

Now you can see a new file named “app.manifest” is added under Properties folder:

When you open app.manifest file, you can see there are some sample settings have been already there, for example:

Move mouse on task bar on the bottom of your Windows 7, right click , you will see “Show the desktop” menu items, Click it when you want to show desktop.

When you come to desktop, the “Show the desktop” menu item will changed to “Show open widows” so that you can switch back to your previous windows.

Way 2: The most simple way: Click the rectangle area which indicates show desktop

Please check your windows 7 task bar carefully, just on the right bottom corner, there is a small and some transparent rectangle, which indicates Show Desktop, When you click it, the desktop will show, click one more time, system switches to your previous window; when your mouse hang over it, the desktop will show at once, when your mouse moves always, it will come back to your current window.

You also have other ways to get the show desktop, but we don’t think they make sense for you. The 2 ways above should be your best and common ways.

When you write web application using PHP or ASP.NET on local PC, maybe you have installed local web server so that you can debug on local machine. However, if you are using Windows 7, you might find localhost can not be opened in web browser or it is very slow to open.

The first step which you have to do is ping your localhost and ping 127.0.0.1, you can find different resolved methods due to your ping results.

For our case, we ping localhost in our Windows 7 and got the result like below:

We were using Google Chrome and Firefox web browsers, which they have some issue when IPv6 is enabled: “Firefox and Chrome are known to be slow on localhost when IP6 is enabled.” ()

The resolution:

1: Run Notepad program as Administrator (In Windows 7);

2: Open the file named hosts in the folder C:\Windows\System32\drivers\etc\ ;

3: Take the comment sign out from this line: # 127.0.0.1 localhost The full content like the following:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost

Now you go back to your Chrome or Firefox web browser, the localhost site will be OK.

There are lots of software which we are running still need Windows XP Operating System. So how can you do if you only have Windows 7?

It is a good news if your software can be installed on Windows 7 without any problem first. Maybe you can run it directly without any problem.

But if you really have problem when run your software, Then maybe first you can try the most simple solution:

change the setting of Compatibility mode: Right click the icon of your software on Desktop or from Start menu, select “Compatibility” tab and see the page looks like the following:

Check on “Run this program in compatibility mode for”:

Then you can select a item from a dropdown list. Note the list will be generated by Windows 7 automatically due to your program. so the Dropdown list of operating system will be different due to your program. The following is another software Compatibility dropdown list:

You can see above list does not include Windows XP versions because the program ONLY support Vista and Windows Server 2008 SP 1;

More operations:

Above we just talked about the most simple solution, but sometimes even you have already set Compatibility Mode, your program still can not run correctly.

In this case we can choose “Troubleshoot compatibility”: Right click your program and see the popup menu, choose the menu “Troubleshoot compatibility”:

The Windows 7 will start to troubleshoot:

Select a case which matches your problem:

For our case we chose the first option in above screen, and then, we got the following screen to ask which OS version that our program could run before:

Ask to start the program first and then can test for fit settings, then you click “Start the program…” button to run program, and then click “Next” button:

The system will complete troubleshooting and ask you to save current setting for this program.

If your program still can not work correctly, you choose “No, try again using different settings” and then system will go back to let you choose other problem case which you can select:

In Windows 7 and Vista, when you run a software, you might need a permission.

When we use Visual Studio 2010, there is no problem when you run Visual Studio 2010 itself, and write code, and debug, and run your application.

However, if your application needs some permission, for example, your application need to “Run as Administrator”, you can set some permission in your application. and then, no matter when you try to debug or run directly your application, you will see the following popup window:

This task requires the application to have elevated permissions

– Restart under different credentials – Cancel the task and return to Microsoft Visual Studio

You can follow the guide to choose “Restart under different credentials” and then your Visual Studio can run as Administrator in the second time. But, why don’t let your Visual Studio 2010 run as Administrator automatically and then you do not need to restart ?

The following show how to set Visual Studio 2010 run as administrator automatically:

1: Go to Start and choose “Microsoft Visual Studio 2010”, right click it and choose “Properties”

2: You will see properties windows as following:

Choose the “Compatibility” tab page and check on “Run this program as an administrator”.

We have a Windows Forms solution which includes multiple sub projects, and since long time, we used Visual Studio 2005, and then 2008, now we are using Visual Studio 2010 to develop this solution.

We never gotten this kind of compile error on Windows XP when we convert the solution from lower Visual Studio version to higher Visual Studio version. But this year we moved OS from Windows XP to Windows 7 64-bit OS, we got some compile issues, one of the error is the following one:

There were some .resx files bring error: Object reference not set to an instance of an object

We searched lots of reference help information through internet, finally we found a solution but we are not sure the exact reason ( but some people think it might be the Visual Studio 2010 bug on Windows 7 64-bit):

Our Windows Form Solution was from old version of Visual Studio, and also we have multiple team members, so some of sub project set the target .NET platform is 2.0, other sub project might be 3.5 or 4.0, the error came from the project which we set to 2.0:

But in our .resx file, we found the following code:

Some reason lead our code has lots of “Version = 4.0.0.0” lines of code.

So all what we did is change all “Version = 4.0.0.0” to “Version = 2.0.0.0”

However, later you will find some of hardware might not work correct exactly, for example: the touchpad, you can not use scrolling feature when you view webpages. That indicates we have not installed a “exact” driver for touchpad.

Well, how we can make the touchpad work correct is that we can ONLY to find its driver. However, Dell never supported a Windows 7 driver for studio 1535. and they do not recommend to install Windows 7 on studio 1535 since they mentioned hardware not support.

Now we can “open” our mind: Dell does not provide Windows 7 drivers, but they provided Vista drivers. Windows 7 was built based on Vista, so why we don’t try to install Vista drivers on Windows 7?

OK, let us try now.

Go to Dell’s support web page for studio 1535, and select drivers for “Windows Vista 64 bits” operation system, and set category to “Mouse & Keyboards”, see below:

And now you can see the result list, there is a driver for Alps TouchPad, because there is only one TouchPad, so we suppose it should be the one we need, so just download it.

After download the file (the file name is R192617.exe) and double click to run and install it.

There was no any error occurred when we installed, so it should work. After we finish the installation, restart your laptop.

Now let us look at how to set the touchpad so that the touchpad can be disable automatically when an external mouse installed.

In your Windows 7, go to Control Panel, choose Hardware and Sound

then choose the “Mouse” item under “Devices and Printers” in the next screen:

Now you will be happy to see the Dell TouchPad setting screen !

For setting TouchPad, just click the touchpad graphic, then you will see the setting window, for our requirement, we want to disable the touchpad when an external mouse pluged in, so we choose Device Select Button Settings

We have a C# application which built in Windows XP using Visual Studio 2010, when we install this application to a 64-bit Windows 7 PC, we got the following error message in a popup windows:

Retreving the COM class factory for component with CLSID{0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC} failed due to the following error:80040154 Class not registered (Exception from HRESULT: 0x80040154(REGDB_E_CLASSNOTREG)).

The reason is because our project is using a 3rd party dll file or a COM component which ONLY support 32-bit operation system, but our project set the target platform to AnyCPU, like following (right click the project name and you will see the window):

The solution is easy, just change platform target to ‘x86’ and rebuild the application again: