'Duplicate Controller exception with external DLL

In my server-application I start the application with:

 public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            // Perform configurations
            GlobalConfiguration.Configure(WebApiConfig.Register);            
        }
    ...
    }

The WebApiConfig.Register-Method looks like:

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.MapHttpAttributeRoutes();
       
        config.Formatters.XmlFormatter.UseXmlSerializer = true;
    }
}

All controllers defined are loaded correctly and can be called.

Now I've encountered the problem, that also Controller-Classes that exist in references (DLL-References) are created. So I get a duplicated-controller-exception for some controllers.

How can I configure my IIS-Application to only load Controllers from my current namespace?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source