Unity and VS2008 Beta SP1 has problem

May 14, 2008 at 12:03 PM
Hi all

I am using unity and MVC Preview 2 to build the application.

It works fine before but after I install the VS2008 SP1. The following code execute twice but it execute once only before.

  protected override IController GetControllerInstance(Type controllerType)
        {
            if (controllerType == null)
            {
                throw new ArgumentNullException("controllerType");
            }
            if (!typeof(IController).IsAssignableFrom(controllerType))
            {
                throw new ArgumentException("Type requested is not a controller", "controllerType");
            }

            return _container.Resolve(controllerType) as IController;
        }

Since it execute twice times, the controllerType will contains NULL and create run-time problem.

Anyone could help?

May 14, 2008 at 2:25 PM
Hi all

I solved this problem and this problem is related to CSS !!!

The SP1 could trap the error if a CSS contains no picture but it just prompt out the NULL problem which looks not related to CSS.

However, this error won't  be trapped before install SP1.
Jul 3, 2008 at 11:31 PM
I have the same problem,

Can you be more specific as to what caused the problem on your end?
Jul 4, 2008 at 2:45 AM
Try to install FireBug in FireFox and load your application. It will show you what files or CSS couldn't be loaded, fix it and try again.
Jul 4, 2008 at 5:30 PM


hnchan wrote:
Try to install FireBug in FireFox and load your application. It will show you what files or CSS couldn't be loaded, fix it and try again.

Ya, I tried that, but to no avail. So I created a new controller with a blank view (no CSS or Javascript at all) and I have the same problem.  I've tracked the issue down to the fact that GetControllerInstance() fires a second time when the application is initialized.  Subsequent calls to the same controller throughout the life of the session do NOT cause the error, it's just the first time.  Debugging the RouteData.Values I discovered that it is coming back the second time looking for "favicon.ico" as the controller value, which would imply a css problem as you suggested.  However, there is no favicon.ico file anywhere in any of my css, js or code files, nor is there an icon file of that name in my source directory.

Very strange bug.

For now, what I've done is check the RouteData in the event that the controller is null before throwing the exception.  Quite an ugly hack, but it solves the problem for now.