The World’s Leading Microsoft .NET Magazine
   
 
timstall

Donate Today!

Search Box

 

Calendar

««Sep 2010»»
SMTWTFS
    1234
567891011
12131415161718
19202122232425
2627282930

My RSS Feeds








Mailing List

Most Popular Tags

                                                           

Silverlight Xaml error: "Length cannot be less than zero. Parameter name: length"

posted Thursday, 10 April 2008

I was getting a strange Silverlight compile error in my Page.xaml the other day (while migrating stuff from 1.1 Alpha to 2.0 Beta):

Length cannot be less than zero.
Parameter name: length

At first it sounds like I was setting a wrong value - like trying to reference the "-1" position on a string. But, it actually was a constraint in what namespaces Xaml allows.

 

In 1.1 Alpha, this would be ok:

xmlns:Tank.Core="clr-namespace:Tank.Core;assembly=Tank.Core"

Which you could then reference like so:

<Tank.Core:Dashboard x:Name="MyDashboard" />

However, that line kept throwing the error when I tried to compile.

 

It seems like if I remove the period ".", then it works again, like so:

xmlns:Tank1="clr-namespace:Tank.Core;assembly=Tank.Core"

<Tank1:Dashboard x:Name="MyDashboard" />

Strange. I'm not fully sure why, maybe some parsing thing with periods "." in beta, but it was good to have a work-around.

tags:  

links: digg this    technorati    




1. Philip left...
Saturday, 27 September 2008 8:32 pm

I got the same error. When adding a namespace with a period in it. This would have taken me forever to debug. Thanks for posting.


2. JOGgernaut left...
Friday, 27 August 2010 6:43 am

I had the same error when erronously declaring namespace references with dots '.' in XAML.

Don't do this:

  • xmlns:Abc.De="clr-namespace:AbraCadabra.Deutch"

but rather

  • xmlns:AbcDe="clr-namespace:AbraCadabra.Deutch"

Notice the dot.