July 2008 - Posts
Today I faced a problem during the SharePoint server migration that I'm working on. First I made the backup for the database and restored it on the destination server, but it didn't work very well. The root site collection didn't work, I just received a "404 Page not found" error from it.
So I chose to import/export every site collection from the entire web application, and surprise....another error. But this time I received the "Failed to compare two elements in the array" error message during the root site collection export.
This is one of the annoying error messages from SharePoint, but a visit to Live Search and the answeer comes! Steven Van De Craen a SharePoint MVP suggested that the problem is caused by an invalid Feature registration, and then he provided a tool to enumerate all site features and display which is invalid, allowing its removal from within the application.
Details: http://www.moss2007.be/blogs/vandest/archive/2008/04/28/stsadm-o-export-fatalerror-failed-to-compare-two-elements-in-the-array.aspx
Great news for those who has Sandisk's U3 Flash Drives. At its last update (U3), Windows Vista has now become a supported OS for the U3 system.
Before Windows Vista SP1, the virtual CD-ROM drive that U3 used to load wasn't detected correctly. After SP1, this virtual CD-ROM drive has become detected an audio disc but still didn't load the U3 menu, what actually didn't help.
But after the U3 system driver update, it just started working on Windows Vista.
For those who don't know the U3 system, it is a technology developed by Sandisk that allows not only the installation of softwares directly at the Flash Drive but also password protects the Flash Drive.
Some time ago I've posted (on my brazillian blog) about the partnership between Microsoft and Sandisk, I don't know if this update become available because of this partnership, but I'm sure that good things will come.
Have a great week.
This is an interesting feature that I saw in one of the feeds that is on my list. Follow the text and reference:
The yield keyword in C# is pretty powerful and expressive, but it doesn’t seem to be very widely known about. In this post we’ll take a quick look at what yield does and then I’ll post a follow-up that looks at what the compiler generates for you. Let’s start by looking at a simple (and contrived) example:
private static readonly string[] StringValues = new string[] { "The", "quick", "brown", "fox",
"jumped", "over", "the", "lazy", "dog" };
static IEnumerable<string> TestIterator()
{
foreach(string value in StringValues)
{
yield return value;
}
}
The return type for the TestIterator method is IEnumerable<string>, but you can see that we don’t have a return statement in the implementation. Instead, we’re using the yield return statement to return each item that we want the caller to operate on. The compiler automatically generates a class that implements IEnumerable<string> for us. We can call this function using the following code:
foreach(string value in TestIterator())
{
Console.WriteLine("In foreach:{0}", value);
}
This code will iterate over the IEnumerable<string> instance that is returned from the TestIterator method. In this example we’ve simply iterated over an existing collection, so we’re not providing much functionality! A more interesting example would be for a binary tree such as:
class BinaryTree<T>
{
public T Item { get; set; }
public BinaryTree<T> Left { get; set; }
public BinaryTree<T> Right { get; set; }
}
In this case, the yield keyword makes it a breeze to add IEnumerable support. First, we add IEnumerable<T> to the implemented interfaces and then we just need the code below to provide the implementation:
public IEnumerator<T> GetEnumerator()
{
yield return Item;
if (Left != null)
{
foreach (T t in Left)
{
yield return t;
}
}
if (Right != null)
{
foreach (T t in Right)
{
yield return t;
}
}
}
This code returns the item for the current node and then recurses into the items from the left and right hand of the tree – how easy is that? This is one of the big advantages of the yield keyword: it allows you to write readable and concise code to produce an iterator.
Stay tuned for part 2, when we’ll take a look at the code that the compiler generates for us...
Reference:
http://blogs.msdn.com/stuartleeks/archive/2008/07/14/a-closer-look-at-yield.aspx
More Posts