Erro no Expression Blend: “failed to compare two elements in the array”
Friday, March 6th, 2009Autor: ricardo.fiel
Nota: Como encontrei pela net algumas pessoas com o mesmo problema sem solução, vou fazer o post em inglês e português, na esperança que possa ajudar quem passar pelo mesmo.
[EN]
After some time working on a Silverlight project, switching between Visual Studio 2008 and Expression Blend 2 SP1, I decided that today was a great day to clean the house a bit – aka Refactoring. Cleaning done, project running without problems until I tried to open it in Blend and get the error “failed to compare two elements in the array”, which made it impossible to open the solution in Blend, but had no problems in VS.
After trying some ideas I’d seen on the web (commenting the code in Page.xaml.cs), looking at the .sln and .csproj files hoping to find some wrong configuration, nothing. Everything remained the same. By unloading all the projects and reloading them one by one, I realized the problem was in a class library where I’d placed a web reference that was, before, in the web application. Hmmmmm… but I really want the web reference in the class library! Yep, but Blend doesn’t want it there! Both the class library and the web app were targeting version 2.0 of the .NET Framework (due to integration requirements with other application, which, in the meantime, was decided that were no longer necessary).
Hmmm… what if it is a service reference? So I converted the class library and the web app to .NET 3.5 and added a service reference to the web service I was calling. Let’s try opening this in Blend…. BINGO! Works! By the way, now that we’re in 3.5, I might as well do some more cleaning and refactor some XmlElement-related code to the wonderful LinqToXml.
Summarizing: It looks like Blend doesn’t like web references. Migrating to 3.5 and to a service reference solved the problem.
[PT]
Depois de algum tempo a trabalhar num projecto em Silverlight, alternando entre o Visual Studio 2008 e o Expression Blend 2 SP1, decidi que hoje era dia de arrumar um bocado a casa – aka Refactoring. Casa arrumada, projecto a correr sem problemas até que tento abri-lo no Blend e depáro-me com o erro “failed to compare two elements in the array”, o que tornava impossível abrir a solução no Blend, mas sem qualquer problema no VS.
Depois de experimentar algumas ideias que vi pela net (comentar o código do Page.xaml.cs), andar pelos ficheiros .sln e .csproj na esperança de encontrar alguma configuração errada, nada. Tudo na mesma. Fazendo unload de todos os projectos e adicionando um a um outra vez, identifiquei que o problema estava numa class library onde tinha colocado uma web reference que anteriormente estava na web application. Hmmm… mas eu quero a web reference na class library! Pois, mas o Blend não quer! Tanto a class library como a web app tinham como target a versão 2.0 da .NET Framework (devido a requisitos de integração com outra aplicação que, entretanto, se decidiu já não serem necessários).
Hmm…. então e se for uma service reference? Converti a class library e a web app para .NET 3.5 e adicionei então uma service reference para o web service em questão. Vamos lá então tentar abrir isto no Blend…. BINGO! Works! E agora que estamos em 3.5, aproveito para arrumar a casa mais um bocadinho e converter um código XmlElement-related para o maravilhoso LinqToXml.
Resumindo: Parece que o Blend não gosta de Web References. Passar para 3.5 e para uma Service Reference resolveu o problema.
. Please don’t hesitate to ask questions, show me your deep zoom and Silverlight projects or just say hello.