Saturday, April 25, 2009

NVidia driver not working after upgrading to Ubuntu 9.04

Ubuntu 9.04 has been released this week and I upgraded my machines to the latest version (download it here).

If you are using dual boot (GRUB) , NVidia drivers, and answered yes to keep your existing version of menu.lst, then you might have the same problem as me.

After I upgraded to Ubuntu 9.04, I get the following error message when restarting the machine:
Ubuntu is running in low-graphics mode

The following error was encountered. You may need
to update your configuration to solve this.

(EE) NVIDIA(0): Failed to load the NVIDIA kernel module!
(EE) NVIDIA(0): *** Aborting ***
(EE) Screen(s) found, but none have a usable configuration.
Although I have restricted drivers enabled, I tried to activate the NVidia driver on System/Administration/Hardware Drivers and nothing happens.



If I open a terminal window and run the following commands below, and then try to reactivate again, you will be able to see some error message displayed on the terminal window:
sudo killall jockey-backend
sudo /usr/share/jockey/jockey-backend --debug -l /tmp/jockey.log
In my case, I got the following error message:
FATAL: Module nvidia not found.
The NVidia module cannot be found because I am running an old version of the Kernel (remember that I said to keep my existing menu.lst version!!) and the NVidia driver is compiled to the latest version.

To check the kernel version I am running I just use the command "uname -r", and it returns 2.6.27-11-generic, but Ubuntu 9.07 comes with 2.6.28-11. So, I need to manually update my menu.lst file to be able to boot to the latest kernel version.

Warning: Only update your menu.lst file if you have done this before. This is not recommended for users that are not experienced with changing menu.lst file. If you are not an experienced Linux user, it is better to not proceed with these changes.


First, run the following commands to see that you have vmlinuz-2.6.28-11-generic:
ls /boot/*2.6.28*
You should be able to see vmlinuz-2.6.28-11-generic and initrd.img-2.6.28-11-generic. Then, backup and edit your menu.lst file:
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.bak
sudo gedit /boot/grub/menu.lst
The safest way is to duplicate your first boot menu entry, then change only this new entry to use the latest kernel version. In my case, I changed it from 2.6.27-11 to 2.6.28-11. I also changed the title to 9.04. This way you still have your previous entries in case you have any problems rebooting and need to restore your previous menu.lst from the backup copy (menu.lst.bak).

Next time you reboot your machine, you can select the first boot entry and then you will see the following:
* Running DKMS auto installation service for kernel
* nvidia (173.14.16)...
And then your Ubuntu will be loaded with the proper video resolution!!

If you have any problems rebooting your machine with the new entry, you can reboot it using an existing entry (or Ubuntu CD) and revert the changes you made by restoring the backup copy: menu.lst.bak (manually created) or menu.lst~ (created by gedit).

Monday, April 20, 2009

LIDNUG LinkedIn .NET Users Group

Linked .NET Users Group (LIDNUG) is an official INETA .NET User Group with online presentations through Live Meeting.

These are some upcoming events in the next few weeks:
You can also have their complete schedule from the following calendar links:
I am looking forward to attend their presentations. Enjoy!!

Saturday, April 04, 2009

Error 1327 Invalid Drive when installing VMware Server

When I try to install WMware Server in Windows 7 (also happened on Vista and XP), I get the message Error 1327 Invalid Drive S:\ and the installation aborts.

For some reason, the VMware installer does not like when you change the default location of your shell folders. I have my Windows shell folders (My Documents, My Music, My Video, My Pictures) mapped to a network drive S:.

The workaround is to temporary change your shell folders back to the default location. An easy way to do it, it is by changing the User Shell Folders registry key. Be careful when editing your Windows registry, so use the following steps at your own risk.

1. Run regedit.exe

2. Locate the following key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

3. Click on File, Export and save this key to your desktop.

4. Change all entries that uses your mapped drive (S: in my case) to the default one (%USERPROFILE%).

5. Now, Install VMware Server.

6. After installation completes, restore your User Shell Folders registry info by double clicking on the file saved on step #3.

That is, you were able to install VMware server and also keep your shell folders at you custom location. I hope VMware folks fix this issue on their installer. Other people were also having this same issue when installing VMware tools.

Saturday, March 28, 2009

VMware is slow or hangs on Ubuntu when running virtual machines from NTFS partitions

I have an external hard drive (WD My Passport, highly recommended!) where I keep all my virtual machines and use it with my desktop (Windows 7) and laptop (Ubuntu 8.10). When I use Ubuntu as host, WMware hangs when starting virtual machines stored on my external HD (NTFS partition). If I copy these VMs to the host ext3 partition, then VMware works fine.

In order to run virtual machines stored on a NTFS partition by using VMware on a Linux host, you will need to add the following entry to your configuration file (.vmx file):

mainMem.useNamedFile="FALSE"

This entry will disable paging files and VMware will work fine, often with a much better performance. For more details, see here. After I added this entry to my .vmx files, I was able to successfully run all my virtual machines from the NTFS partition.

Saturday, March 21, 2009

Fixing Windows 7 Beta 64bit Blue Screen of Death (BSoD) tdx.sys

I have been using Windows 7 Beta (Build 7000) on my laptop since it became available. I have been very pleased with this new version and looking forward for its RTM. Today, I decided to install Windows Beta 64bit on my desktop machine as well. Everything was fine, until I started getting the following Blue Screen of Death (BSoD):




After some research, I found that the problem is related to my antivirus (AVG Fee) and a network shared drive (DNS323 - Linux based using Samba).

After multiples BSoD, Windows 7 finally suggested a solution to my problem:




The problem occurs because of an incorrect behavior in a system component that occurs when Server Message Block (SMB) connections go over Transport Driver Interface (TDI). My network shared drive uses Samba, which is a reimplementation of SMB. The hotfix can be found at:
This hotfix has not undergone full testing. That is why it is not available under Windows Update. So, it is intended only for systems or computers that are experiencing the exact problem that is described here. You need to register to receive it by email. After installing this hotfix, my problem was solved, and I can finally enjoy Windows 7 Beta on my desktop machine!!

Sunday, March 08, 2009

Memory Management of Windows SharePoint Services (WSS) Objects: Best Practices and SPDisposeCheck Tool

The Windows SharePoint Services (WSS) 3.0 object model, provides a set of classes to work with WSS data. These objects can be used to read and write data to the WSS store. The WSS object model contains many objects that implement the IDisposable interface, which primary use is to release unmanaged resources. The Dispose method of IDisposable is intended to be called by consumers of the object, directly or with the using statement, in order to release unmanaged resources.

Best Practices for Disposing WSS objects

Two common WSS objects that implement IDisposable are SPSite and SPWeb. SPSite represents a site collection, and SPWeb represents a single site. A common mistake is to use these objects without disposing unmanaged resources:

// BAD: SPSite and SPWeb will be leaked.
SPSite site = new SPSite("http://server");
SPWeb web = site.OpenWeb();
string title = web.Title;
string url = web.Url;

A better way to write the code above is:
// GOOD: No leaks.
using(SPSite site = new SPSite("http://server"))
{
using(SPWeb web = site.OpenWeb())
{
string title = web.Title;
string url = web.Url;
}
}
The code above was very simple, but you got the idea. Things start getting more complicated when you start combining calls into the same line. This makes harder to catch leaks, since you do not see the implicit referenced object. For example:
// BAD
SPWeb web = new SPSite("http://server").OpenWeb();
The line above, might make you thing that there is only one leak, and you will attempt to fix with the following:
// BAD
using (SPWeb web = new SPSite("http://server").OpenWeb())
{
...
}
The code above will dispose the SPWeb object that is returned by the OpenWeb method, but it will not dispose the SPSite that is created by the new operator. The solution is the same as the first problem:
// GOOD: No leaks.
using(SPSite site = new SPSite("http://server"))
using(SPWeb web = site.OpenWeb())
{
...
}
Working with SharePoint collections also need some attention. When using SPWebCollection objects, you will need to dispose any SPWeb object that is accessed using the [] indexer or with a foreach statement. The same applies for SPSiteCollection. The following code shows how to avoid leaks when using the SPSiteWeb object:

// GOOD: No leaks.
using (SPSite site = new SPSite("http://server"))
{
using (SPWeb web = siteCollection.OpenWeb())
{
foreach (SPWeb innerWeb in site.AllWebs)
{
try
{
// ...
}
finally
{
// Must dispose the collection item.
if(innerWeb != null)
innerWeb.Dispose();
}
}
}
}
A similar approach would be used if you were accessing collection items using the [] indexer. You would need to dispose each object returned by [].

The examples above just show you a few common cases of how to dispose WSS objects, just for you to get the idea. The following article provides detailed explanation of how to detect and proper dispose your SharePoint objects:
You can also look at Roger Lamb's article which complements the article above with lots of examples:SPDisposeCheck Tool

The SPDisposeCheck tool analyzes your assembly and detect if you are disposing WSS objects properly. This tool takes the path to a managed .DLL or .EXE, or the path to a directory containing many managed assemblies. It will recursively search for and analyze each managed module attempting to detect coding patterns based on best practice article above. The tool does not detect all possible unmanaged resources leaks, so you still have to learn the best practices and review your code.

You can install SPDisposeCheck from here. It is a console application, and you should add C:\Program Files\Microsoft\SharePoint Dispose Check to your path.

The usage is:

SPDisposeCheck -debug –xml

The output is a list of potential problems. If you have the PDB symbol file available, then the output will include additional source code information about the error. The -debug option adds additional information to the output. The -xml option outputs the errors to an XML file instead of text, however, the SPDisposeCheck site says that this option is unreliable, and they do not recommend to use this command on this release.

I run this tool with a WebPart that I recently created, and I got the following result:

ID: SPDisposeCheckID_160
Module: CustomCalendar.dll
Method: CalendarGenerator.SharePointCalendarRepository.#ctor(System.String)
Statement: manager := web.{Microsoft.SharePoint.SPWeb}GetLimitedWebPartManager(pageUrl, 1)
Source: D:\Code\CustomCalendar\CustomCalendar\SharePointCalendarRepository.cs
Line: 40
Notes: Dispose/Close was not called on SPLimitedWebPartManager.Web
More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_160
----------------------------------------------------------

Total Found: 1

Well, although I am embarrassed that it found a bug in my code, I am very glad that this tool works! In my code, I am calling GetLimitedWebPartManager which returns a SPLimitedWebPartManager. This returned reference also needs to be disposed.

The following table contains the possible errors, links to the detailed description, and a summary of the solution.

Error CodeSummary Solution
SPDisposeCheckID_110 If you create a SharePoint object with a new operator, ensure that the creating application disposes of it.
SPDisposeCheckID_120 You must dispose the SPWeb objects that are created by SharePoint methods that return other SPWeb objects (such as OpenWeb).
SPDisposeCheckID_130 You must dispose the SPSite object that is returned each time you access SPSite.AllWebs [] index operator.
SPDisposeCheckID_140 It is NOT necessary to dispose the SPWeb object returned by SPWeb.RootWeb. The dispose cleanup is handled automatically by the SharePoint framework.
SPDisposeCheckID_150 You must dispose the SPWeb object the is returned by calling SPSite.AllWebs.Add method.
SPDisposeCheckID_160 You must dispose the SPWeb object the is returned by the SPLimitedWebPartManager.Web property.
SPDisposeCheckID_170 It is NOT necessary to dispose the SPWeb object returned by SPWeb.ParentWeb. The dispose cleanup is handled automatically by the SharePoint framework.
SPDisposeCheckID_180 You must dispose all SPSite objects in the SPWeb.Webs property (SPWebCollection type).
SPDisposeCheckID_190 You must dispose the SPSite object that is created and returned by the SPWeb.Webs.Add method.
SPDisposeCheckID_200 You must dispose the SPSite object that is created and returned by the SPWebCollection.Add method.
SPDisposeCheckID_210 It is NOT necessary to dispose SPContext object returned from calling SPControl.GetContextSite and SPControl.GetContextWeb Methods, since they are managed by the SharePoint framework.
SPDisposeCheckID_220 It is NOT necessary to dispose SPContext objects on your code, since they are managed by the SharePoint framework.
SPDisposeCheckID_230 You must dispose the SPSite object that is returned each time you access SPSiteCollection [] index operator.
SPDisposeCheckID_240 You must dispose the any SPSite object returned from the SPSiteCollection.Add method.


The tool also allows you to ignore a reported issue. If you have investigated a reported issue and are satisfied that it does not represent a problem, then you can add the following attribute to the calling method:
[SPDisposeCheckIgnore(SPDisposeCheckID.SPDisposeCheckID_100, "Ignoring this error")]
To add this attribute to your method, you will need to grab the source code of the attribute class from the file:

C:\Program Files\Microsoft\SharePoint Dispose Check\SPDisposeExamplesSource.zip

One of things to consider, is to run SPDisposeCheck Tool as a post-build event of your assembly. If it reports any issue, then the build fails. Developers can then detect leak problems at build time and troubleshoot them as soon as possible.

Conclusion

The improper memory management of WSS objects can lead to a poor system performance, system crash, or users experiencing unexpected errors (timeouts, page not available), especially under heavy loads. To avoid these problems, developers need to follow best practices for disposing WSS objects, and also use tools, such as SPDisposeCheck, to check if their assemblies are properly disposing WSS objects.

References

Monday, February 16, 2009

Free DevExpress controls and IDE productive Tools

DevExpress is a software development company producing .NET components, controls and IDE productivity tools. They also offer some of their commercial products for free!! The list below contains some of their FREE products that I am aware of. Just register to get your free license:

.NET Controls:
IDE Productivity Tools:

Spring Boot Configuration Properties Localization

Spring Boot allows to externalize application configuration by using properties files or YAML files. Spring Profiles  provide a way to segr...