Question: I am trying to get the main Window of an application written C#.
Application.MainWindow Property does not work :(

uses: 

```
using System;
using System.Windows;

using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
using System.Collections.Generic;

using My;
using MyDialogs;

using System.Xml.Serialization;
using System.Runtime.InteropServices;

using System.Windows.Input;
using System.Windows.Media;
using System.Threading;
using System.Windows.Interop;

```

Answer: 
Idsa,

You may find that a similar question that I had today (which I figured out) may help:

[goin back to my 'routes' - issue with partialviews and areas??](https://stackoverflow.com/questions/6866866/goin-back-to-my-routes-issue-with-partialviews-and-areas)

basically, in your views web.config file(s), reference the namespaces that directly relate to either the root or the areas portions of the site.

worked for me in a very similar error scenario.

**[edit]** - re the custom viewengine. just add the following class to your Models folder (with your own custom paths of course):

```
using System.Linq;
using System.Web.Mvc;

namespace ABC.Web.Site.Areas.Administration.Models
{
    public class ABCViewEngine : WebFormViewEngine
    {
        private static readonly string[] NewPartialViewFormats = 
            new[] {
                    "~/Areas/Administration/Views/Shared/Full/{0}.aspx",
                    "~/Areas/Administration/Views/Shared/Partial/{0}.ascx"
                  };

        public ABCViewEngine()
        {
            base.PartialViewLocationFormats = base.PartialViewLocationFormats.Union(NewPartialViewFormats).ToArray();
        }
    }
}

```

then add the following to your global.asax (Application\_Start()):

```
ViewEngines.Engines.Add(new ABCViewEngine());

```

good luck..
Searches tend to take people here, so I'd like to shard another related item.

I've had issues where the **view won't be returned** due to an **unexpected miss-match of the overloaded method** I meant to be calling, and the actual **method signature match**.

For example, if you have Id as a string, then View("Something",id) will match the overload expecting a string ViewName and a string MasterName...

**Not:**

```
return View("Something",id);

```

My recommendation here is that it can be more clear, and fix this problem, if you provide the parameter names

**But Instead:**

```
return View(viewName:"Something", model: id);

```

These types of problems can happen also in HTML Helper methods, where you often just expect to be able to pass in your model, but if you model is just a string, you might be matching some other overload method signature. (For example, the Action link html helpers.)

Because of this, I recommend just specifying the parameter name, and avoiding the unexpected. Heck, it might even make the expectation of your code just a little more clear.