Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - x:Static with constants won't work (weird error + Class not found)

 
 
Old 12-13-2006   #1 (permalink)
Keith Patrick


 
 

x:Static with constants won't work (weird error + Class not found)

I am trying to use a constant in a resource defined in my App.xaml.
Everything's fine when it's hardcoded, but when I put in an {x:Static
c:Constants.MyConst}, I get a couple of errors. The first one is the
weirdest. As soon as I make the aforementioned change (this is all in
Visual Crash 2005), I get a dialog about App.xaml not belonging to the
project I'm debugging, so it can't enter break mode, "Usually, this
condition occurs when the project was not rebuilt prior to starting the
debugging session (not true), when the assembly file for the project is out
of date (don't believe this to be true, although with 2005's f'ed up
caching, who knows?), etc." Selecting OK gives me an exception: Type
reference cannot find public type named 'Constants'. Error at Line 8
Position 30. I don't see what I'm doing differently from how the
documentation describes, as my namespace appears to be fine, but it's as if
the runtime doesn't even consider the namespace

Here's my markup:
<Application x:Class="MyNS.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="MyNS"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<XmlDataProvider x:Key="{x:Static Member=c:Constants.MyConst}"
Source="pack://siteoforigin:,,,/Data/Objectives.xml"/>
....

And the class is
namespace MyNS
{
#region Referenced Namespaces
using System;
#endregion // Referenced Namespaces

public static class Constants
{
public const String MyConst = "At least this error doesn't make
VS.Net actually crash";
}
}



My System SpecsSystem Spec
Old 12-14-2006   #2 (permalink)
Keith Patrick


 
 

Re: x:Static with constants won't work (weird error + Class not found)

Turns out I *didn't* declare my namespace correctly. For non-XML namespaces,
the xmlns:c decl has to be: "clr-namespace:MyNS"


My System SpecsSystem Spec
Old 12-14-2006   #3 (permalink)
Horst Klein


 
 

Re: x:Static with constants won't work (weird error + Class not fo

Hi Keith
Try to ask in the Blend Forum.
May be you become there faster anseer.

http://www.microsoft.com/communities...&lang=en&cr=US

Good luck
Horst
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Weird: No suitable graphic devices found General Discussion
how to call a static method in a .net class from powershell? PowerShell
Access a static member on a nested static class. PowerShell
Access a static member on a nested static class. PowerShell
Is easier WMI static class access in the works for 1.1+? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46