locked
......does not exist in the namespace......Blend 4 VS 2010 RRS feed

  • Question

  • Every so often I return to blend hoping it will be OK....Ha ha

    I get 'xxxx does not exist in the namespace' in the results pane this seems to apply on ty to the currently loaded page but I do get this for different references in most of my pages, everything builds and runs OK and it is fine in VS2010 but it means I cannot do anything in Blend.

    For example im App.xaml
    xmlns:app="clr-namespace:QR"
     <ResourceDictionary>
          <app:ResourceWrapper x:Key="ResourceWrapper" />
          <app:NotOperatorValueConverter x:Key="NotOperatorValueConverter" />
    </ResourceDictionary>

    The ResourceWrapper is in the QR namespace in the Helpers Folder QR\Helpers, so I tried changing the declaration to xmlns:app="clr-namespace:QR/Helpers"
     
    I accept that I am doing something wrong but I have no idea what/where

    any help?

     


    jnc
    Friday, February 25, 2011 10:38 AM

Answers

  • If your assembly is QR.dll, and it is referenced in your project, you would do it like this:

    xmlns:Converter="clr-namespace:QR;Assembly=QR"

    • Marked as answer by jnc Thursday, March 3, 2011 6:10 PM
    Tuesday, March 1, 2011 6:33 PM
  • Strange...

    If from within VS you highlight in the soultion explorer that cs file with the converters in it you mention above , what build action does it have (in properties pane). Should be Compile.

    Just wondering if Blend is treating some of these cs files as resources and simply embedding them in the assemblies and not picking up changes and VS is being smarter at tracking changes than Blend.


    andrew
    • Marked as answer by jnc Thursday, March 3, 2011 6:09 PM
    Wednesday, March 2, 2011 4:48 PM

All replies

  • I now get this with many of my pages I beleive it is something to do with the way I am referecing my classes in xaml, It all builds OK, I do seem to have full functionality in the app when it is running and VS2010 does not report any errors, just Blend

    I wonder if there is another failing in a page so I am in the process of re-constructing one of my pages bit by bit


    jnc
    Monday, February 28, 2011 1:39 PM
  • One thing that sometimes works is putting the "Assembly=" into your clr-namespace. 

     xmlns:custom="clr-namespace:MyNameSpace;assembly=MyAssembly"

    Tuesday, March 1, 2011 5:47 PM
  • Thank you looks like a good tip but how would I write it exactly I am referencing a range of things from Converters to Data Binders all in c

    xmlns:Converter="clr-namespace:QR;Assembly=Converters.cs"

    xmlns:Converter="clr-namespace:QR;Assembly=http://QR/QR/Bin/Release/QR.dll"

    neither seem to work


    jnc
    Tuesday, March 1, 2011 6:28 PM
  • If your assembly is QR.dll, and it is referenced in your project, you would do it like this:

    xmlns:Converter="clr-namespace:QR;Assembly=QR"

    • Marked as answer by jnc Thursday, March 3, 2011 6:10 PM
    Tuesday, March 1, 2011 6:33 PM
  • Thank you

    no they are not a dll I have found an article with the brief explanation but I don't get it
    I want to reference a class in a c# document which contains many similar classes in the Views folder along with the page I want to add the reference to

    xmlns:Converter="clr-namespace:QR;Assembly=QR"


    jnc
    Tuesday, March 1, 2011 6:55 PM
  • Sorry done some more research and added  

    xmlns:localDBind="clr-namespace:DataClass_DeptBinder;assembly=QR"

    where :DataClass_DeptBinder is a data binder class in the app QR (QR is also the Namespace) this line does not wrror but even after build I cannot use the binder

    <localDBind:DataClass_DeptBinder CollectionChanged="DataClass_DeptBinder_CollectionChanged" x:Key="DataClass_DeptBinderDataSource" d:IsDataSource="True"/>


    jnc
    Tuesday, March 1, 2011 6:58 PM
  • I have tried this : xmlns:localConverters="clr-namespace:QR.Views.Converters;assembly=QR"

    Where converters is a cs file with a 8 classes it works OK in VS listing all 8 classes
    in Blend it just lists 4 classes (the 4 have been in the app longer), I have tried copying one of the '4 classes' and re-naming to check it was not a failing in the class and even the copied one does not show bonkers


    jnc
    Tuesday, March 1, 2011 8:44 PM
  • Hm, usually rebuilding the applicaiton will make them show up.

    Tuesday, March 1, 2011 8:49 PM
  • That is what I expected all along, I have re-installed Expression Studio in the hope...no difference
    I do beleive that there is something either as a setting or in code which is preventing a complete compilation though if I remove one of my WORKING converters it does fail to build

    here are some fragments,
    This is the reference :  xmlns:localMyC="clr-namespace:QR.Myc;assembly=QR"
    I attempt to use the converter like <localMyC: nothing is listed in intellisence
    Both the Converters and the xaml are in the same Views folder
    The App Namespace is QR
    The code is a new class with converters copied HeadConverter does not work in Blend
    FullNameConverterM does work in the other class called FullNameConverter

    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Windows;
    using System.Windows.Data;
    
    namespace QR.MyC
    {
    	<strong><span style="text-decoration:underline">//WORKS IN VS2010 DOES NOT WORK IN BLEND</span></strong>
    	 public class HeadConverter : IValueConverter
      {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
          string retStr = "QuickRota Login";
          if (value != null && value.ToString() != "")
          {
            return "Welcome " + value.ToString().TrimEnd();
          }
          return retStr;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
    			if (value != null)
    			{
          throw new NotImplementedException();
    			}
    			return 0;
        }
      }
    	//FullNameConverter WORKING IN ANOTHER CLASS THIS IS A COPY DOES NOT WORK IN BLEND
      public class FullNameConverterM : IValueConverter
      {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
          if (value != null)
          {
            string FN = value.ToString().TrimEnd() + " " + value.ToString().TrimEnd() + " - " + value.ToString().TrimEnd();
            return FN;
          }
          else
          {
            return null;
          }
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
          return null;
        }
      }
    }
    

    jnc
    Wednesday, March 2, 2011 9:13 AM
  • I have just renamed the fully working FullNameConverter in the fully working class to FullNameConverterM re-built and it is still listed in intellisense as FullNameConverter  though it does not build so, clearly some cache is not clearing
    jnc
    Wednesday, March 2, 2011 9:48 AM
  • jnc,

    To clarify what is your workflow between VS2010 and Blend as it looks as if your projects in each are out of sync?

    If changing a namespace/class etc in vs2010 do you build and save the project each time before going back to Blend? This should re-prompt Blend to reload so as to reflect the current changes.

    If you update a class in VS2010 and then switch to Blend without building then build in Blend it will work with the last version of the project it knows about and tends to result in the errors you are seeing. 

    The same goes for editing in Blend and then switching back to VS2010.

    If changes to an external library are not updating the other thing you can try is (from VS2010): remove the project reference from the consumer project. Recompile the library and then re-add the reference. Build and Save.

    Looks like the cache used by Blend is located (on my XP box):C:\Documents and Settings\Andrew\Local Settings\Application Data\Microsoft\Expression\Blend\Project Assemblies\

    I tend to work with classes and code centric stuff in VS2010.


    andrew
    • Edited by Andrew 99 Wednesday, March 2, 2011 11:45 AM cache info
    Wednesday, March 2, 2011 11:39 AM
  • Thanks

    I normally use VS2010 as well I visit Blend to play with the look and feel
    I have been runnig with either or both I had not previously built before swithing to the other, makes sense but most of my work today has been with only Blend

    as well as that I have deleted Intellesense and  Project Assemblies in C:\Users\MyName\AppData\Local\Microsoft\Expression\Blend (Win7)

    I also removed, rebuilt and added the project reference

    no difference


    jnc
    Wednesday, March 2, 2011 12:34 PM
  • Strange...

    If from within VS you highlight in the soultion explorer that cs file with the converters in it you mention above , what build action does it have (in properties pane). Should be Compile.

    Just wondering if Blend is treating some of these cs files as resources and simply embedding them in the assemblies and not picking up changes and VS is being smarter at tracking changes than Blend.


    andrew
    • Marked as answer by jnc Thursday, March 3, 2011 6:09 PM
    Wednesday, March 2, 2011 4:48 PM
  • Nice Idea but yes it says compile I have fiund a version from December which refreshes changes in this file very nicely so I am going to import the objects till it squeaks

    Not really worth all this trouble tho'


    jnc
    Wednesday, March 2, 2011 5:46 PM
  • I have marked both you and Leo as answerers because of the interest you showed and the tips you gave me, but to get the problem solved I went back to a Backup copy which was reflecting changes post build.

    I then copied/Imported the pages and code from the application which was failing (not as bad as I anticipated)

    I did the import > page import - Build- test > page import - Build- test etc. step by step and as I suspected all the bits I brought in worked ok, nothing causing an inability to recognise changes in code.

    So I guess the problem is buried somewhere in the files I did not import or Blend itself.

    My observations are

    ·     When you build in VS the build can still fail in Blend even though the app runs fully

    ·     Errors in Blend can be page specific ie load a page you see errors, close the page and go to another you only see errors for the loaded page

    ·     VS cannot spot all errors in xaml

    ·     There is a file or folder or something which does not necessarily refresh at build or it is flagged as don't compile - pointed out by Andrew 99 [though in my case VS said “do compile”]


    Fortunately I am not dependant on Blend
    Thank you both for your help

     


    jnc
    Thursday, March 3, 2011 6:29 PM