Code Project

Link Unit

Wednesday, February 03, 2010

When caching is enabled for the XmlDataSource that is control tree it requires a UniqueID that is unique throughout the application

We were using XmlDataSource in code behind and assigning the same to a menu.
XmlDataSource XmlMenu = new XmlDataSource();
This was resulting in "When caching is enabled for the XmlDataSource that is control tree it requires a UniqueID that is unique throughout the application" - Use an ID for XmlDataSource .
The solution for which is specifying the ID of XmlDataSource .
XmlMenu.ID = "Menu1";
Reason:XmlDataSource class internally calls a private method called CreateCacheKey.Now, if you are using XmlDataSource without an ID in Code-Behind. This might throw an exception - "When caching is enabled for the XmlDataSource that is not in the pages control tree it requires a UniqueID that is unique throughout the application." This is due to the absence of the UniqueID ,which is used as part of the caching key.Without ID all instances would try to use same caching key. Setting a distinct ID will resolve the problem.

Monday, February 01, 2010

Change default language from VB to VC#

Visual Studio 2005 is installed on all of our development PCs.Initially our projects were in VB so while installing we choselanguage "Visual Basic" instead of "Visual C#.Now .We are working more on C# and when a new project/site is to be created, we should take care which language we chose otherwise it will get created in default language which is VB in our case.So we wanted to have VC# as our default lanaguage. Searched google/newsgroups to figure out solution.

Solution
#1. We can do this by using Registry by changing this registry key:HKCU\Software\Microsoft\VisualStudio\8.0\General\NewProjectDialogPreferredLanguage. It was VB in our case we can change it to VC#. The same key also exist in HKEY_USERS. We might do a search for that value name and just change to VC# anywhere you find it.Though this option is not preferrable.

#2 If we wish to remove VB and use only C# in our programming environment then we could do that using add/remove programs and click on change button for the installation. Just uncheck vb and check off C#.Though this option is also not preferrable.

#3 The easiest option to do so is
a) Choose Tools -> Import and Export Settings...
b) Select Reset All Settings and click Next
c) Select whether you would like to save the current settings and click Next
d) Select the settings you want to use(change the language to VC#) and click Finish

Hope it helps the visitor.