WPF and Designer error

Nov 1, 2010 at 9:26 PM

hello,

what's up with the error:

"The type 'n:BridgeViewModelBehavior' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built."

Is there a ways to fix it and get the designer working in VS 2010?

Nov 1, 2010 at 9:51 PM
Edited Nov 1, 2010 at 10:01 PM

Hi,

I did everything with your tutorial :(

In my references I have: nRoute.Framework; System.Windows.Interactivity

In my view I have:

<Window x:Class="MyApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:n="http://nRoute/schemas/2010/xaml"
        Title="MainWindow" Height="350" Width="525">
    
    <i:Interaction.Behaviors>
        <n:BridgeViewModelBehavior />
    </i:Interaction.Behaviors>
    
    <Grid>
        
    </Grid>
</Window>
I also get error in my App.xaml file:
<n:Application x:Class="MyApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Views/MainWindow.xaml" xmlns:n="http://nRoute/schemas/2010/xaml"> <n:Application.ApplicationLifetimeObjects> <n:nRouteApplicationService/> </n:Application.ApplicationLifetimeObjects> </n:Application> 
"'ApplicationLifetimeObjects' was not found in type 'Application'."
"'n:nRouteApplicationService' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built."
Nov 1, 2010 at 10:02 PM

No, the namespaces are correct, I was just changing them for posting here, but in my code they are the same :)

Nov 1, 2010 at 10:18 PM

Yes, I've noticed that in Blend the designer works ok.

Also, I was doing a project some time ago in SL using nRoute and the same thing was happening :(

Coordinator
Nov 1, 2010 at 10:50 PM
Hi, just double check you are not using wrong assembly files - so for SL4 check you are not using WP7 or WPF assemblies. I've seen such issues before, probably because the file names are the same across platforms.

Rishi
>
Nov 1, 2010 at 10:53 PM

I've added the assembly which was in the Desktop folder in the .zip downloaded from codeplex for the WPF project.

Coordinator
Nov 2, 2010 at 10:15 AM

Well, if it's not an erroneous assembly then it's more of a VS designer issue - which in my experience comes around somewhat randomly. And as of now, I have no solution for it except perhaps suggest that you should rely on Blend for the designer experience. 

Cheers,
Rishi 

Nov 2, 2010 at 5:09 PM

I'am using Blend for my major design work, but I souldn't be forced to launch Blend every time I need to make some change and the designer in VS should work nevertheless :)

Nov 5, 2010 at 11:31 AM

Here is the exact error I'm getting:

Cannot create an instance of "IList".
   at Microsoft.Expression.DesignModel.Core.InstanceBuilderOperations.InstantiateType(Type type, Boolean supportInternal, Boolean supportProtected)
   at Microsoft.Expression.DesignModel.InstanceBuilders.ClrObjectInstanceBuilder.InstantiateTargetType(IInstanceBuilderContext context, ViewNode viewNode)
   at Microsoft.Expression.DesignModel.InstanceBuilders.ClrObjectInstanceBuilder.Instantiate(IInstanceBuilderContext context, ViewNode viewNode)
   at Microsoft.Expression.DesignModel.Core.ViewNodeManager.Instantiate(ViewNode viewNode)
Coordinator
Nov 5, 2010 at 5:40 PM

I'll dig into this issue, with the next release - which I'm preparing. I suppose it might have something to do with the the design-time instantiation. 

Cheers,
Rishi 

Nov 8, 2010 at 7:15 PM

I've noticed one quick situation. When I create a project based on your template downloaded from VS code gallery - the designer works. But when I create an application based on the steps you provide on your blog - it doesn't.

Coordinator
Nov 8, 2010 at 7:23 PM

Very strange.. I'll try and reproduce it to see what's the difference in the proj file.

Cheers,
Rishi 

Nov 8, 2010 at 7:38 PM

One more observation. The designer work when I create the Navigation app. When I create the "normal" app from template I still get the IList exception as previous.

Feb 1, 2011 at 8:02 AM

Hi Rishi,

 

For IList error, I have modifed Application.cs v0.4.5.100 with :

 

public List<IApplicationService> ApplicationLifetimeObjects
        {
            get
            {
                if (_applicationLifetimeObjects == null)
                {
                    _applicationLifetimeObjects = new List<IApplicationService>();
                    if (!nRouteApplicationService.IsInitialized)
                    {
                        return _applicationLifetimeObjects;
                    }
                }

                if (_applicationLifetimeObjectsWrapper == null)
                {
                    _applicationLifetimeObjectsWrapper = 
                        new ReadOnlyCollection<IApplicationService>(this._applicationLifetimeObjects);
                }

                return new List<IApplicationService>(_applicationLifetimeObjectsWrapper); 
            }
        }

 

 

And it's work fine for me...

 

Cheers,

Hervé

Feb 10, 2011 at 9:35 PM

Hi Herve,

I also fight with this issue. I put in your change, and it seems to work fine, but ...

I get some other problem before:

<

i:Interaction.Behaviors> 

     <nBehaviors:BridgeViewModelBehavior />

</i:Interaction.Behaviors >

And I get ... BridgeViewModelBehavior    .... not found error.

I whipe out this lines and try to find out the effects of your change isolated and yeh it works really.

I put in the lines again, and I get the IList error again. I have only to click into to control, nothing else, and get the error.

So, there must be some other problem around.

With best regards



Gerhard

Mar 2, 2011 at 12:16 PM

Hi all,

use this line:

xmlns

:n=http://nRoute/schemas/2010/xaml

and the patch posted earlier

public List<IApplicationService> ApplicationLifetimeObjects
        {
            get
            {
                if (_applicationLifetimeObjects == null)
                {
                    _applicationLifetimeObjects = new List<IApplicationService>();
                    if (!nRouteApplicationService.IsInitialized)
                    {
                        return _applicationLifetimeObjects;
                    }
                }

                if (_applicationLifetimeObjectsWrapper == null)
                {
                    _applicationLifetimeObjectsWrapper = 
                        new ReadOnlyCollection<IApplicationService>(this._applicationLifetimeObjects);
                }

                return new List<IApplicationService>(_applicationLifetimeObjectsWrapper); 
            }
        }
and you never have design errors again.
The patch isn't included in the code base now, so after getting the newest set, you have to patch again.
With best regards
Gerhard