Unable to activate copy of windows after upgrading Windows XP

by Viper 29. September 2009 05:40

In my previous post Fix STOP: 0x0000007B (OxF8968640, 0xC0000034, 0X00000000, 0x00000000), I described come remedies to that problem. The thing that started the whole thing was the following message.


This copy of Windows must be activated with Microsoft before you can log on. Do you want to activate Windows now?

I had Windows XP Home installed on my Dell Latitude E6500 laptop. I decided to upgrade it to Windows XP Professional. The upgrade completed without any problems. After laptop was rebooted, I had my nice login screen come up with all the user accounts listed. I clicked on my account and I got the above message. Since I have valid user license for Windows XP Professional, I clicked on "Yes" on the dialog box. Nothing happened. Usually a wizard starts that walks you through activation steps. I tried rebooting few times, booted in safe mode, repaired my installation. Nothing worked at all. I thought I could log into safe mode to do activation. Well, it told me that I can not activate copy of windows in safe mode. I tried to reboot with "Safe mode with Networking Support". That did not go very well because operating system refused to do so telling me that I have to activate copy of the windows before I could do so. After digging around and calling my preferential technical support at microsoft, I came to know the following things and fix for the problem.

  • Windows Activation Wizard Depends on Installation of Internet Explorer. So much for not forcing users to have to install IE.
  • Upgrade from Windows XP Home Basic to Windows XP Professional wiped my previous installation of IE8

So from above two issues you can see that I am in catch 22 situation and there was no way that activation wizard was going to come up. So here is the solution to the problem.

  • Goto another machine that has CD/DVD burner
  • Download full installer of Internet Explorer 8 (IE8)
  • Burn IE8 on CD/DVD
  • Now log in into "Safe Mode" on machine with activation problem
  • Insert CD with IE8 installer
  • Install IE8 on the machine
  • Reboot the machine
  • Now when This copy of Windows must be activated with Microsoft before you can log on. Do you want to activate Windows now? message dialog box pops up, click "Yes"
  • This should bring up activation wizard and you should be able to complete your activation of copy of windows and use your machine normally.
Give your advice to big bosses and make money

Views: 1657

Tags:

Windows | Windows 7 | Windows XP

Fix STOP: 0x0000007B (OxF8968640, 0xC0000034, 0X00000000, 0x00000000)

by Viper 28. September 2009 07:32

Two days ago I decided to upgrade my Dell Latitude E6500 laptop from Windows XP Home Basic to Windows XP Professional. I decided not to do a clean install and use Upgrade option at install time. It upgraded fine. When I tried to log into the machine, i got the error message that I need to activate this version of Windows before I could use it. Well that is another story. I tried few things and decided to do a clean install. So I inserted my boot disk and made the laptop boot from it. All the drivers copied fine and when it went to step of Starting Windows Executive, BAM. I get the dreaded BSOD with error code STOP: 0x0000007B (OxF8968640, 0xC0000034, 0X00000000, 0x00000000). Well, this is a new laptop and was botting fine when I upgraded OS version. So it did not seem logical to think that hard disk is corrupted or some controller is failing. I remember that I had similar issue couple of years ago when I tried to upgrade OS on one of my Dell Precision Workstation. Then it hit me that at that time the problem was because of SATA drivers not being loaded from Windows XP install CD. And I had to ask Dell for installer CD that was used on that desktop. When you see this kind of error when you do any of the following:

  • Reinstall OS from disk other than manufacturer
  • Change your hard disk configuration
  • You got SATA/RAID drives

First try to see if you can find your original OS disk that came with the machine or ask the manufacturer for a new one. There are different solutions proposed like disabling SATA option in BIOS. I do not feel comfortable with those options because it may introduce issues that may affect performance of your machine. I will strongly suggest using disk that has appropriate disk drivers.

Give your advice to big bosses and make money

Views: 2498

Tags:

Windows | Windows 7 | Windows XP

TF31002: Unable to connect to this Team Foundation Server

by Viper 25. September 2009 12:14

First let me tell that I am new to TFS. I got tasked with installing and configuring TFS2008 for our development team. Everything was going smooth till the point when I tried to connect to TFS server from Team Explorer and get the following error thrown at me.

Microsoft Visual Studio
TF31002: Unable to connect to this Team Foundation Server: mytfsserver.
Team Foundation Server Url: http://mytfsserver:8080.

Possible reasons for failure include:

- The Team Foundation Server name, port number or protocol is incorrect.
- The Team Foundation Server is offline.
- Password is expired or incorrect.

For further information, contact the Team Foundation Server administrator.

When I looked at the error, it looked more like some kind of network error. But then I tried to access some other web services on the same error and nothing looked wrong. Well that was not very helpful. So far I was trying with Internet Explorer and I know that Team Explorer pretty much uses IE control behind the scene to connect to any kind of web services. So I fired up Fire Fox. It prompted me for my windows credentials. And now I got different kind of error but told me to look at the event logs. When I opened event log there were lot of errors from TFS and the last one looked like below:

Team Foundation Server

TF31001: Team Foundation cannot retrieve the list of team projects from Team Foundation
Server mytfsserver. The Team Foundation Server returned the following error: 
Team Foundation services are not available from the server.

Technical information (for administrator):

  TF53011: domain\username is not a licensed user..

So I opened up Team Explorer on TFS server itself and added my domain account into licensed users group and everything worked fine after that.

Give your advice to big bosses and make money

Views: 5283

Tags: ,

Visual Studio

How to fix corrupted project and item templates in Visual Studio?

by Viper 23. September 2009 05:09

While working on an ASP.Net application on Visual Studio 2008, I ran into a problem. When I right clicked on the project to add a new page into the project, i got the error message that no templates could be found. Well, that was kind of strange that I was working on the project night before and I did not run into such problems. Recently Microsoft has become pretty good about their error reporting providing some initial hints. In this case the message said that I should look in the event logs to find more details. The event logs had the following error message.

The global template information is out of date. Regenerate the templates by running 'devenv.exe /installvstemplates' or reinstalling the application. Note: corrective action requires Administrator privileges.

In the past I would have took the option of reinstalling Visual Studio. But this time the error message provided an alternative to fix the issue by reinstalling templates by running a command line option. And it worked. After I ran the command, Visual Studio 2008 was back to its normal templates.

Give your advice to big bosses and make money

Views: 1855

Tags:

Visual Studio

How to start command window as administrator on Windows7

by Viper 23. September 2009 04:44

Every now and then you run into situations where you need to perform some command line action on your windows machine. And then you see this instruction along with other instructions for that operation. Note: corrective action requires Administrator privileges. This was not a problem till Windows XP because if your account was part of Administrators group you were granted the rights to perform that action. But on Windows7 that is not the case. Even if your account is part Administrators group, you are not running as Administrator. On Windows7 you have to use Run as administrator option to launch certain application.

To start a command prompt we all go to Start menu and use Run option to launch command window or in Windows7 you simply type Cmd in following window in start menu and hot enter.

command window in Windows7

This will start your command window but it will be running under your context and not as administrator. To get it to run as administrator, instead of hitting Enter, use following key combination and you will have your command window running as Administrator.

Shift + Enter

To confirm that your command window is running as administrator, you will see Administrator prefixed in the title of the command window as shown below.

command windows run as administrator
Give your advice to big bosses and make money

Views: 2295

Tags:

Windows 7

How to fix windows socket stack corruption on Windows 7

by Viper 11. September 2009 08:15

This morning I opened the flap of my laptop and windows started resuming from hibernation. I noticed that all resources on the machine were getting consumed and eve after good 10 minutes the machine did not recover completely and CPU usage was still 100%. Instead of waiting any more I did a hard reboot of the laptop. After restart, I started getting all kind of weird error messages thrown at me. Errors that I have never seen before. The network service failed, event notification service failed, networking was not working and all kind of errors related to network. I thought my network slots on mother board has failed. So I decided to plug-in wireless broadband network modem to get connected. Well there was surprise I get error "Windows Sockets could not be initialized". Well that was kind of indication that something is seriously busted now. I did the usual routine of trying to run machine in safe mode. Well, i could not access event logs as well for any errors at that point because it complained about event log service not being started on the machine.

Since I was getting WinSock initialization error from my broadband card connectivity so I decided to reset WinSock stack on my machine. I ran the following command from command line.


netsh winsock reset


When the command started running first message I got in the console was saying nitialization function INITHELPERDLL in IPMONTR.DLL failed to start with error code 10107. That is very typical message you will see when winsock stack is corrupted. The command ran for few seconds and then I restarted the machine as it asked me to. That fixed the whole issue for me.

Once the machine started normally, I was able to look into System event log. Well, there was huge number of network related errors from last night. Some of the errors were:

  • A timeout was reached (30000 milliseconds) while waiting for the Net.Tcp port Sharing Service service to connect.
  • The network location awareness service terminated
  • The IP helper service terminated
  • The network link is down

How this information helps you if you are running into similar issues on your machine.

Give your advice to big bosses and make money

Views: 7287

Tags: , ,

Networking | Windows 7 | Windows XP

How to Change file or folder owner on Windows 7?

by Viper 2. September 2009 06:19

This morning I tried to update source of one of open source libraries for one of my applications. The source is hosted under subversion. Since I had upgraded my machine from Windows XP to Windows 7 so I had to reinstall TortoiseSVN tool. The tool installed fine without any issues and shell extensions installed nicely as well. And I got the ability to right click on the code folder and click on SVN Update. So far so good. The update dialog box comes up and after few seconds I get the error message

read-write: Access is denied

I realized that I am not using Windows XP anymore. And I am dealing with Windows 7 UAC now. Why did I get the error? Here are the reasons:

  • The folder was created when I was using Windows XP. Although I have not changed my login name on the machine but I have a new SID now. So I am not the folder any more. See the following two snapshots. First one shows who the current owner is and second one shows that owner's SID is unknown, indicated by a ref ? on left side of SID.

  • Even though I am logged in with administrator account, I am not technically administrator. I am just a Protected Administrator (PA). If you are upgrading from Windows XP then you are already familiar with User Access Control (UAC) technology and all the restrictions introduced with it. On Windows XP, an administrator account had previleges on all folders in the system. But on Windows 7, protected administrator account can not do that.
  • If you look at the permission set for the standard users account on the machine, you will notice that it does not have Write permissions on the folder. You can see it in the following snapshot.

For an application to update these files, you will have to do one of the following things:

  • Your application should be running under the credentials of the file owner. Since that SID is invalid now, that is not an option any more.
  • Get your application to "Run as administrator" or relax UAC. This is something that can be done as last resort if all else fails.
  • Change ownership of the file or folder to new user account. This is the option I like the most because I am not compromising UAC settings and I am doing the correct thing of changing ownership to valid account. This is what I am going to explain in next section.

How to change file ownership in Windows 7?

These are some very straight forward steps with slight caveat here and there. Of course there are going to be some caveats, its Windows. Here are the steps that will describe how to change owner of an existing file, especially when existing file owner account is not valid any more.

  • Right click on folder or file in Windows Explorer and select Properties menu option. This will bring up Properties dialog box for that file or folder.
  • Select Security Tab. It will bring up view as shown below and click on Advanced button
  • Now you will have Advanced Security Settings dialog box. In this dialog box, select Owner tab at the top and it will bring up view as shown below.
  • Now you will have Owner dialog box as shown below. In this view, select the user account that needs to be assigned new owner of the file or folder. If this is a folder, then you can select Replace owner on subcontainers and objects if you want the owner change to propagate to all child nodes under this folder as well. And then click on Apply button for change to take into effect. If you have lot of subfolders or hierarchy is too deep, then it may take few seconds to minutes for changes to apply.

Now your application should be able to make changes to files if it is running under your account.

Give your advice to big bosses and make money

Views: 7178

Tags:

Windows 7

How to check for loopback IP address on Windows 7

by Viper 2. September 2009 06:02

Transition from Windows XP to Windows 7 has been raising new issues every day during development of desktop as well as web applications. Most of these are not issues per se. They are changes that were introduced during Windows Vista and are part of Windows 7 as well. This piece of information has to do with network protocols on Windows 7. Here is what happened. I am developing a web application. One of the things I had to do in the application is to check if the request URL is from localhost or loopback address then do something different otherwise follow normal routine. So I was comparing Request.UserHostAddress with standard loopback address of 127.0.0.1. It was working fine. Then I started an instance of IE and tried to test the page. Well, nothing seemed to work. When I debugged the code, I saw that value of Request.UserHostAddress was ::1 instead of 127.0.0.1. By looking at the IP address I could tell that it was standard IPv6 loop back IP address. Actually the loopback address on an IPv6 network is 0:0:0:0:0:0:0:1 which is abbreviated as ::1. Then I paid close attention to IPAddress class in .Net framework. There is a method IsLoopback that you can use to test for loopback address. And you will use Parse method to create instance of IPAddress object. After making these changes, my implementation looked as below.


private void GetUserFromIp()
{
 UserGeoLocator geoLocator = new UserGeoLocator();
 _userLocation = null;
 var ip = IPAddress.Parse(Request.UserHostAddress);
 if (IPAddress.IsLoopback(ip) ||
  string.Compare(Request.UserHostAddress, "127.0.0.1", 0) == 0)
 {
  _userLocation = geoLocator.GetUserLocationByIp("68.xxx.xxx.xxx");
 }
 else
 {
  _userLocation = geoLocator.GetUserLocationByIp(Request.UserHostAddress);
 }
}

IPv6 is enabled by default on Windows Vista as well as Windows 7. If you use Visual Studio Development Server to debug your application, you will notice that loopback address is in IPv4 format but if you use IIS to debug your ASP.Net application, the loopback address is in IPv6 format. To avoid any issues like this, using IsLoopback makes the implementation neutral to format because framework will take care of interpretting the IP address correctly when you use Parse to create instance of IPAddress object.

You can diable use of IPv6 on Windows 7 by following instructions in How to disable certain Internet Protocol version 6 (IPv6) components in Windows Vista, Windows 7 and Windows Server 2008. If you are not using any format specific implementation, then you do not have to do that and I would not suggest doing it if you are not comfortable dealing with changing registry entries.

Give your advice to big bosses and make money

Views: 2247

Tags: ,

ASP.Net | Windows 7

Media Player and Feed Sync services slowing down windows

by Viper 1. September 2009 11:28

I have been running Windows 7 for quite some time now. Lately I started seeing that every now and then machine will consume almost 100% CPU. Especially if machine resumes from hibernation it was taking few minutes to get it started completely and respond to mouse and keyboard events. So I started looking into Task Manager. I noticed that there was good amount of activity happening. And most of the activity was for operations that I did not care or I did not use or I did not know about. There were 2 processes that I am going to mention here.

Windows Media Player Network Sharing Service

I noticed that wmpncfg.exe process was consuming close to 35% of CPU. Then I looked in Service Control Manager and found this service. Interesting thing was that the service was configured to run Manually but it was already running. I never started it. This is what the description of this service says.

Shares Windows Media Player libraries to other networked players and media devices using Universal Plug and Play

If you are not using media player to share your content, then you really do not need to run this service. Change the status of this service to Disabled.

Feed Sync

Second process that i noticed was msfeedssync.exe. This process was actually waking up at regular interval and consuming all the resources. The name pretty much tells that it has something to do with news feed synchronization. I had configured Windows Mail to read some feeds some time back. But then I had removed it from there. Windows Mail also adds these feeds to Internet Explorer as well. You can click on the feeds in Internet Explorer by clicking on Favorites button. The left pane has a tab for Feeds. You can see in the image below that there is one entry for news feed.

Now click on Tools > Internet Option menu option. It will bring up Internet options dialog box. Click on Content tab. At the bottom of the view you will notice section Feeds and web slices. Click on Settings button. It will bring up following dialog box. Notice that by default all feeds are set to be synchronized every 15 minutes. Turn this off if you are not using IE as news reader or you want to synchronize the feeds manually.

After I made these 2 changes, I saw significant improvement in performance of my laptop.

Give your advice to big bosses and make money

Views: 853

Tags:

Windows | Windows 7

Using Windows Notepad for non-english languages

by Viper 25. August 2009 04:53

Currently I am working on an assignment that involves updating a web site in 4 different languages (English, Chinese, Arabic and Spanish). The company provided all the translated documents. Now it was just matter of copy paste from non English documents to the pages. Well, that turned out to be a nightmare task for me because this was first time I was working with Arabic and Chinese language pages. I thought it would be simple task of cut and paste from Microsoft Word document to HTML editor for those pages. Well that did not work quite well because MS Word wants to copy its HTML tags as well. So I decided to use my good old technique of copy the text on to notepad and then from notepad to HTML editor. Well that did not go very well either because notepad could not render Arabic and Chinese text. And I was not in position to enable east asian language support on the machine.

Since Microsoft has done good job of updating very elementary tools like Paint so I thought of trying Notepad on my Windows 7 machine. And it worked like a charm. The notepad did render Chinese and Arabic text correctly. I could not thank Windows 7 enough to save my day.

Give your advice to big bosses and make money

Views: 1855

Tags:

Windows 7

IE runs very slow on Windows 7 after installing Java Run Time

by Viper 20. August 2009 10:27

This was just a nightmare experience with Java Run Time on Windows 7. I wanted to run live stock ticker application from my brokerage firm. That application is a java applet. For few years Microsoft has stopped installing JRE on Windows machines, thanks for litigation case with Sun MicroSystems. Anyways, I downloaded JRE from Sun's web site and installed it. First thing i notice is that when I launch Internet Explorer it taked 5-8 seconds for home page to come up. And subsequent page navigation is slow as well. When I looked in Task Manager I saw that ssvagent.exe process is consuming close to 90% CPU. Then I launched a second instance of browser. Now I have another ssvagent.exe process launched and consuming all the CPU it can. I could not surf any pages without waiting for 5-10 seconds per page load time. I immediately installed Java Run Time from my machine and everything back to normal.

I did some search about the process and found that this is some known issue. There is an official bug report about it on Sun's site as well. You can read about it on this link ssvagent.exe and jbroker.exe need to be signed. The bug has been opened and closed multiple times. And it looks that it still has not been fixed. At least now you do not get Windows UAC dialog box.

Give your advice to big bosses and make money

Views: 7660

Tags: ,

IE | Windows 7

Use SnipTool and Sticky Notes in Windows 7

by Viper 18. August 2009 16:36

There are two very useful tools in Windows 7 that I absolutely love. Sticky Notes and Snip Tool

If you are migrating from Windows Vista then you probably have seen these tools in the form of gadgets. But for users who are upgrading from Windows XP, these tools are going to something they will find themselves using all the time.

Sticky Notes

The name pretty much tells the whole story. Yes, these are like sticky notes that you can post on your display. Click on the menu option in Start menu and it will bring up a blank sticky note on your display. Write whatever note you want to write on it and it will stay sticky on there. If you want to create more notes, you will notice there is a + button the note. If you click it, you will start a new sticky note. If you are big fan of sticky notes to keep track of your tasks then you will love it.

Snip Tool

If you are like me who like to take snap shot of applications or messages or things like that to convey visual description of message or description etc. then you are going to love this tool. Now you do not have to do Print Screen and then save the image in some graphic editor and then edit it to cut out the relevant portion. All that pain is gone with this new tool. When you click on the menu option in Start > Accessories it will bring up a small dialog box. Click on New button. Your screen will turn into very light color and a snipping cursor will become active. Simply mark the area on the screen that you want to snip and tool will automatically open the sliced view into editor and then you can save it.

There are more cool new tools available in Windows 7 and I will keep updating my posts with more information about those tools as well.

Give your advice to big bosses and make money

Views: 39652

Tags:

Windows 7

Accessing Documents and Settings folder in Windows 7

by Viper 10. August 2009 04:58

If you try to access Documents and Settings folder in Windows 7, you will get the following message box thrown at you.

[Window Title]
Location is not available

[Content]
C:\Documents and Settings is not accessible.

Access is denied.

[OK]

First, Documents and Settings folder is not visible when you look in system drive. In my previous post How to set folder view options, i discussed how you can change the options to make system files and folders visible. Now you have the folder visible but its not accessible even when you are logged in as administrator. Now Documents and Settings is actually a link to another folder Users in your system drive. Yes, this is the folder where all the users related data is stored. Under this folder you will find folders for all users who have ever logged into the system and some of default system users as well. You can access individual users folders. This is where you will find folders like My Documents, My pictures, Favorites etc. You will notice a lot of these folders have a blue curved up-arrow icon with it. Yes, this indicates that these folders are shortcut or links to actual physical location of the folders. And you will not be able to access these folder from these links. If you have change the folder options to view hidden files and folders, you will be able to see actual folders like My Documents, Local Settings etc. You can access these folders to get to physical location of data. One other important folder that you need to know about it Local Settings. This is also a link to actual location in user folder. There is no hidden Local Settings folder. You will find another hidden folder AppData. Click on this folder and you will find following sub-folders.

  • Local
  • LocalLow
  • Roaming

This is where you will find the folders that you are used to seeing under Local Settings and Application Data folders. In general you if you are looking for folders that used to be in Documents and Settings folder, look in the following folder (assuming you have installed operating system in C drive).

C:\Users\{user name}

This little piece of information about folder structure in Windows 7 should help you get started in exploring more folders that you may otherwise think have been removed since Windows XP. If you have any questions, please feel free to fire question(s) my way. I will be glad to answer as much as i can.

Give your advice to big bosses and make money

Views: 116346

Tags:

How to change Folder View Settings in Windows 7

by Viper 10. August 2009 04:37

In earlier version of Windows, we used to have a top menu in windows explorer and one of the items used to be Tools and under that there used to be option for Folder View. I used to use that to toggle options like:

  • Show hidden files, folders and drives
  • Hide extensions for known types
  • Hide protected operating system files
  • File sharing wizard
  • ... and more

When you launch windows explorer in Windows 7, you will notice that Tools menu option in not there. Now there is a new menu item Organize. Under that you will find sub menu item Folder and Search Options.

Click on Folder and Search Options menu item. This will bring up dialog box Folder Options that following three tabs.

  • General
  • View
  • Search

Click on View and it will show the folder options that you can use to toggle different options about folder view.

Give your advice to big bosses and make money

Views: 22376

Tags:

Windows 7

ASP.Net version getting set to 4.0 in IIS manager

by Viper 6. August 2009 05:26

I have been working with VS2010 and ASP.Net 4.0 for quite some time now. Every time i create a web application, I just use the handy feature of Visual Studio of creating virtual directory for web application. Last week I was manually creating virtual directory for a web application using IIS manager. Since the application was targeting ASP.Net 2.0, so from ASP.Net tab of IIS, I selected V2.0 framework. Now there is a confirmation dialog box that comes up when you change ASP.Net framework.

Changing the Framework version requires a restart of the W3SVC service. Alternatively, you can change the Framework version without restarting the W3SVC service by running: aspnet_regiis.exe -norestart -s IIS-Viirtual-Path Do you want to continue (this will change the Framework version and restart the W3SVC service)?

Everything is good so far. Moment i accessed the application in browser, I got the following error message.

Server Error in '/Foo' Application.
The application domain or application pool is currently running version 4.0 or later of the .NET Framework. This can occur if IIS settings have been set to 4.0 or later for this Web application, or if you are using version 4.0 or later of the ASP.NET Web Development Server. The <compilation> element in the Web.config file for this Web application does not contain the required 'targetFrameworkMoniker' attribute for this version of the .NET Framework (for example, '<compilation targetFrameworkMoniker=".NETFramework,Version=v4.0">'). Update the Web.config file with this attribute, or configure the Web application to use a different version of the .NET Framework.

I was little surprised because I never configured virtual directory for this application to use ASP.Net 4.0. I fired up IIS manager and went to ASP.Net tab. There it was, the application was configured to use ASP.Net 4.0. So I changed it back to use ASP.Net 2.0. Accessed the application in browser and got the same error again. I experimented with the drop down box for ASP.Net version in IIS manager. The application will get configured to use ASP.Net 4.0 no matter what option I picked from the drop down box. It seems that this is some bug in beta version of Visual Studio 2010 installation.

For now the work around I have been using is to let Visual Studio create virtual directory for my web application. It targets the correct ASP.Net version and modifies IIS meta data correctly.

Give your advice to big bosses and make money

Views: 3338

Tags: , ,

ASP.Net | IIS

How to send data from Javascript to Silverlight control to render charts

by Viper 31. July 2009 15:09

Download Demo Project

I have been discussing use of jQuery to send AJAX request to server to get some data every X number of seconds to get server time and calculate some latency numbers. Now it is time to add some color to it. The numbers that I am getting is great and provide some useful information. But having a visual of how these numbers are varying with time will enhance utility of these statistics. So I decided to add some charts to show these latency numbers are varying with time. In this article I am going to show how you can pass the data obtained from server using AJAX request to a Silverlight application hosted on the page. This silverlight application uses charting control from Silverlight toolkit. Lets see how all this fits together to get this to work.

Bridge between Javascript and Silverlight component

In one of earlier posts, How to setup communication between silverlight applications, I discussed how you set this bridge up. The sample project for that article was done using Silverlight 2. The mechanism to set up the communication bridge has not changed in Silverlight 3. So all those concepts still apply for this project as well. The following code snippets shows declaration of a method decorated with ScriptableMember attribute to let silverlight framework know that this methos is to be exposed to javascript. And in constructor of the page, HtmlPage.RegisterScriptableObject method is called to register the class to be exposed to javascript. I do not want to expose all my properties, fields and methods to javascript. So I have not added scriptable attribute on class itself. I want to control what is exposed and what is not.


public MainPage()
{
	InitializeComponent();
	HtmlPage.RegisterScriptableObject("ClockDataClient", this);
	SetupChartDisplay();
}
		
[ScriptableMember]
public void PutNewClockData(string xtx, string data)
{
	AddDataPointToPlot(data);
}

This completes what needed to be done from silverlight application to expose its end points to javascript. Now we are going to see what is done on pages to communicate to silverlight control.

Setting up the page

First thing you need on the page is to include your Silverlight control. On Default.aspx you will find the following declaration of object tag that will host the control.


<object id="clockDisplayPlugin" data="data:application/x-silverlight-2," 
  type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/ClockLatency.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="onLoad" value="onLoadClockDisplay" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="" style="border-style:none"/>
</a>
</object>

All this code was generated by wizard when I added test paste to my project. I added a new param declaration to handle load event. This event is fired when Silverlight control has been loaded. On lets see what all javascript is required to send message to silverlight control.


function onLoadClockDisplay(sender, args) {
 objClockDisplay = sender.getHost();
}

function sendLatencyData(data) {
 if (null != objClockDisplay) {
  objClockDisplay.Content.ClockDataClient.PutNewClockData("", data);
 }
}

As you can see, in load event handler I saved the reference to Silverlight control object. Then from my ajax request code, every time I got the data from server, I call sendLatencyData method. This method calls PutNewClockData method that I exposed from control using ScriptableMember attribute. This call constitutes of four parts.

objClockDisplay.Content.ClockDataClient.PutNewClockData

objClockDisplay is reference to our silverlight plugin. Content is the property on plugin object through which control's methods are exposed. ClockDataClient is the key that was used to register the class as scriptable in our control. PutNewClockData is the name of the method.

Setting up charting control in Silverlight component

I used charting control from Silverlight Toolkit for my project. I decided to use column chart to display latency numbers over time. In silverlight application project, I added the following XAML on MainPage.


<chartingToolkit:Chart Title="Clock Latency" x:Name="latencyChart" BorderThickness="2">
 <chartingToolkit:Chart.Series>
  <chartingToolkit:ColumnSeries Title="Latency" DependentValueBinding="{Binding Latency}" AnimationSequence="Simultaneous" />
 </chartingToolkit:Chart.Series>
</chartingToolkit:Chart>

In codebehind i created a collection to save data sent from javascript and attached the column series to that collection. I only keep last 11 entries in the collection.


void SetupChartDisplay()
{
 ColumnSeries cs = latencyChart.Series[0] as ColumnSeries;
 foreach(var lItem in cs.LegendItems)
 {
  lItem.Visibility = System.Windows.Visibility.Collapsed;
 }

 latencyChart.Width = 500;
 (latencyChart.Series[0] as DataPointSeries).ItemsSource = DynamicCollectionItemsSource;
}

You can see it was pretty simple to set this whole up and get javascript to send data to silverlight control and render the charts using those numbers.

Click to see demo

Feel free to send any comments or suggestions.

Give your advice to big bosses and make money

Views: 4073

Tags:

HTMLParser | JQuery | Silverlight

Could not load file or assembly 'System.Web.Silverlight' or one of its dependencies

by Viper 30. July 2009 11:41

This morning I was working on a prototype Silverlight application that I developed with Silverlight 2. I copied the project to my new shiny Dell XPS with GTX280 video card. Moment i hit F5 to debug the application, i get the following exception.

Could not load file or assembly 'System.Web.Silverlight' or one of its dependencies. The system cannot find the file specified
Line 2: <%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>

It just took me by surprise. I was like, I did not change anything in the project in couple of months and I have new installation of all visual studio tools. After digging through release notes and documentation of Silverlight 3 SDK and tools, i found out that Microsoft has decided to get rid of ASP.Net Silverlight server control that was part of Silverlight 2 SDK. Since I have fresh install of Visual Studio 2008 and tool and I never installed Silverlight 2 SDK on this workstation, I did not have that server control.

Microsoft is recommending to use object tag to insert Silverlight components on the pages now. It is not big deal but it was nice having that server control do all the dirty work behind the scene for you and add object with appropriate parameters and other values. If you still want to continue using that Silverlight server control, you can copy System.Web.Silverlight assembly from other machine or you can install Silverlight 2 SDK.

There seem to be few issues with that ASP.Net server control but none are serious that you could not keep the control and use workaround to get over the issues.

Give your advice to big bosses and make money

Views: 8942

Tags:

Silverlight

how to insert new elements on page in reverse order using jQuery

by Viper 28. July 2009 06:35

prepend enries using jquery

I have been extending the current sample clock synchronization application to add some more features to show more capabilities of jQuery. In the last update I added functionality to display latency numbers when service was called every X number of minutes. If you will let the page running for quite some time you will see how quickly the entries get appended to the display. What we really want is that latest entries should be displayed at the top. So basically instead of appending the new entries, we want to prepend the new entry to the last entry added. We are in luck here. jQuery does offer couple of methods here that makes it easy. prepend, prependTo, before, insertBefore methods are your friend here. It turns out that all these methods get mapped to one function behind the scene, insertBefore. Following code snippet from the application shows entries are added in reverse order.


var elLastLatencyEntry;
var elLastMessageEntry;

function displayLatency() {
 var elToAppend = null;
 if (latency == -1) { elToAppend = $("<p>Initializing</p>"); }
 else { elToAppend = $("<p>" + latency + " ms</p>"); }
 if (null == elLastLatencyEntry)
 { elLastLatencyEntry = elToAppend.appendTo(elLatencyDisplay); }
 else { elLastLatencyEntry = elToAppend.prependTo(elLastLatencyEntry); }
}

You can see from the code that I save the last entry that was added in a variable for later use. This avoids over head of finding the latest entry again and again every X number of seconds.

Give your advice to big bosses and make money

Views: 3554

Tags: , ,

AJAX | Javascript | JQuery

This operation requires IIS integrated pipeline mode - PlatformNotSupportedException

by Viper 22. July 2009 12:31

While experimenting with setting up of Cache-Control headers on Response object, i ran into following exception when I tries to access Headers property of Response object directly.


Exception type: PlatformNotSupportedException 
Exception message: This operation requires IIS integrated pipeline mode.

If i had read the documentation for Headers property I would have not done it at the first place. Here is what documentation says. The Headers property is only supported with the IIS 7.0 integrated pipeline mode and at least the .NET Framework 3.0. So if you are setting an headers in the response on IIS6 or earlier, use AddHeader method of Response object.

Give your advice to big bosses and make money

Views: 5294

Tags:

ASP.Net

How to set correct cache control headers for AJAX response

by Viper 22. July 2009 03:43

I have been developing AJAX enabled applications before the term AJAX was coined. I have been doing it for so long that some of things that I do come kind of naturally. And one of the things that I always do is to make sure that response is not cached to ensure that client is never working on stale response even though it sent new request every few seconds. So I have a small piece of code that I pretty much use in all applications that sets some headers.


Response.ContentType = "text/plain";
Response.Expires = -1;
Response.CacheControl = "no-cache";

These are not just the only headers but gives you an idea how cache was being control. I never ran into any trouble with any applications till last week when I was told that our application is filling up Temporary Internet Files folder of the users. This was the first time ever I was reported such issue and actually this was first time I observed this behavior in my applications. So I fired up Fiddler to see whats going on with my requests. I looked at the response headers and saw the following.

First, I was not expecting to see Cache-Control: private. So that was little out of whack. Second, the expiration time was correct because I always set to an hour behind the response time to make sure that it is stale for caching. I have been using the same caching utility routine for so long that I did not suspect that something is wrong there. Then I looked inside Temporary Internet Files folder again and noticed that this was the only request that was being saved in the folder, others were not. So I looked at the implementation and found that the server side implementation for this request was not using my standard utility to set cache headers. Following is the code snippet that I ad in place. Well why i changed the implementation for this particular call is whole different story.


Response.ContentType = "text/plain";
Response.Expires = -1;

Notice that it is missing Cache-control : no-cache header. That explained everything. After I added this header, everything went back to normal. So I decided to do some experiment to observe behavior of setting different headers.

No Cache-control: no-cache header on any call

You will notice that from my earlier post How to serialize multiple AJAX calls in jQuery, I have two AJAX calls being made. And you can see from snapshot above that both are being saved in Temporary Internet File folder.

Cache-control: no-cache header set on one request only

Now you can see that only one request is being saved in the folder and other has disappeared.

Cache-Control:no-cache header set on all requests

Well, there is nothing to show here in Temporary Internet Files folder because nothing is being saved there any more. But here is the snapshot of response headers as seen in Fiddler.

Now you can see that no-cache header and pragma has been set correctly.

Set cache-control header correctly

As more and more applications are using AJAX or Web2.0 style of implementations, if you do not set these cache control headers correctly, you will see that browser cache folders will accumulate lot of entries. It is not that big of a deal as far as application working goes because this temporary cache will not grow beyond specified limits for a particular browser. But it will hurt performance of other internet sites that you visit because their content will not be found in cache and will have to reloaded from server again. Other performance hit you will take is that now browser has to spend an extra CPU cycle to save these entries on the disk.

Give your advice to big bosses and make money

Views: 3905

Tags: , , , , ,

AJAX | ASP.Net | JQuery

Powered by BlogEngine.NET 1.5.1.7
Theme by Naveen Kohli

By Categories