locked
Local UserControls return Type reference cannot find public type RRS feed

  • Question

  • I am working in VS 2008 and in Blend 1.01083.0.

    I have a particular class (UserControl or other) in MyLib that I bind to in XAML. The XAML is also within MyLib.

    Blend requires this format to locate the bound class xmlns:MyLib="clr-namespace:MyLib;assembly=MyLib" while visual studio requires xmlns:MyLib="clr-namespace:MyLib". I can only make both Blend and VS happy if I move the bound class to a different library, then both can use the xmlns:MyOtherLib="clr-namespace:MyOtherLib;assembly=MyOtherLib" format.

    Am I doing something wrong or is this a bug in Blend or VS 2008?

    Thanks for any help. Right now I am forced to place my UserControls or other classes in a separate library just to be able to use them in Blend and VS 2008 at the same time.

    Jeff


    PS
    Will this forum ever be renamed to not include the (Pre-release)? Last time I checked VS 2008 has been released.
    Thursday, February 7, 2008 9:25 PM

Answers

  • Thanks - if you get a chance that would be good - here's what I did:

     

    - Start Blend

    - New Control Library Project called MyLib

    - Added a couple of Buttons to UserControl1.xaml

    - Added Window1.xaml

    - Built

    - Added UserControl1.xaml to the toolbox in Blend

    - Added UserControl1 to Window1.xaml

     

    The UserControl displayed and project built successfully and the XAML looked like this which is what I would expect

     

    mark

     

    Code Snippet

    <Window
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     x:Class="MyLib.Window1"
     x:Name="Window"
     Title="Window1"
     Width="640" Height="480" xmlns:MyLib="clr-namespace:MyLib">

     <Grid x:Name="LayoutRoot">
      <MyLib:UserControl1 HorizontalAlignment="Left" Margin="45,30,0,0" VerticalAlignment="Top" Width="162" Height="104"/>
     </Grid>
    </Window>

     

     

     

     

    Tuesday, February 12, 2008 11:10 PM

All replies

  • I moved this thread from WPF forum to Cider forum for better answers

    Thanks
    Monday, February 11, 2008 6:05 AM
  •  

    Jeff,

    I just played around with this in Blend and VS and for what I tried (based on your post) both Blend and VS worked correctly for me - the xmlns:UntitledProject7="clr-namespace:UntitledProject7" syntax works fine for me in both projects -I must be missing something - are there a simple set of steps I can go through to understand the issue you are seeing? Failing that can you send me a project that illustrates the issue?

    thanks

    mark

    Tuesday, February 12, 2008 9:10 PM
  • Thank your for looking into this problem.

    My project gets more complicated everyday, but I don't think that is the problem.

    The reference you gave was xmlns:UntitledProject7="clr-namespace:UntitledProject7". I believe Blend will put the assembly reference in like xmlns:UntitledProject7="clr-namespace:UntitledProject7; assembly UntitledProject7" which seems to be the key to the problem. In my case VS will work with the assembly reference only if it is a not a local assembly. Blend complains everytime I take the assembly reference out.

    The first time I ran into this was when I had a UserControl in MyLib which I wanted to use in a Window which was also located in MyLib (e.g. xmlns:MyLib="clr-namespace:MyLib;assembly=MyLib" -- MyLib:UserControl). I was forced to put the UserControl in a separate assembly and use xmlns:MyUCLib="clr-namespace:MyUCLib;assembly=MyUCLib" to work around the issue. This was kinda annoying because now I have one UserControl in it's own assembly which might be good down the road if I have fify UserControls, but not now.

    I can work out an example later this week, but I have a thursday deadline now which forces me just to workaround this issue.

    Thanks,
    Jeff



     
    Tuesday, February 12, 2008 9:47 PM
  • Thanks - if you get a chance that would be good - here's what I did:

     

    - Start Blend

    - New Control Library Project called MyLib

    - Added a couple of Buttons to UserControl1.xaml

    - Added Window1.xaml

    - Built

    - Added UserControl1.xaml to the toolbox in Blend

    - Added UserControl1 to Window1.xaml

     

    The UserControl displayed and project built successfully and the XAML looked like this which is what I would expect

     

    mark

     

    Code Snippet

    <Window
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     x:Class="MyLib.Window1"
     x:Name="Window"
     Title="Window1"
     Width="640" Height="480" xmlns:MyLib="clr-namespace:MyLib">

     <Grid x:Name="LayoutRoot">
      <MyLib:UserControl1 HorizontalAlignment="Left" Margin="45,30,0,0" VerticalAlignment="Top" Width="162" Height="104"/>
     </Grid>
    </Window>

     

     

     

     

    Tuesday, February 12, 2008 11:10 PM