Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication'.

Topics: Web Client Software Factory, Project Management Forum, UIP Application Block discussion, User Forum
Apr 28, 2008 at 2:51 PM

I have built Web Application using WCSF I have sub Web Projects in my Main Website Project.

Now I have Created Virtual Directories(IIS 5.1) for my WebProject and SubWebProjects under the main WebProject

When I am runing Main Web Project It runs fine But when I want to explore or browse to any of the SubWeb Project It gives me Following Error.

Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


InvalidCastException: Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication'.
Microsoft.Practices.CompositeWeb.Authorization.WebClientAuthorizationModule.Init(HttpApplication context) in c:\Builds\WCSFv2-BlocksCI\PublishBinariesBuildTemp\Source\CompositeWeb\Source\CompositeWeb\Authorization\WebClientAuthorizationModule.cs:45
System.Web.HttpApplication.InitModulesCommon() +66
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1006
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +259
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +114
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +350




--------------------------------------------------------------------------------

Please Help me in Solving this issue. I am really runing out of my time.

Apr 28, 2008 at 8:14 PM
Edited Apr 28, 2008 at 8:18 PM

maisuriya wrote:

Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



Based on the above error message and the following statement it would seem that you created subwebs as applications under your primary web and did not provide a Global.asax within the application. This would be consistent with the error you reported in the message thread Taking More time to Load the application because the subweb application becomes an application (not subweb), i.e., there will be no ~/Shared/Master.master in your subweb (it actually exists in your perceived parent web).

maisuriyaWhen I am runing Main Web Project It runs fine But when I want to explore or browse to any of the SubWeb Project It gives me Following Error.

To duplicate the above error in your main web simply rename your global.asax file. The IHttpModule More on HttpModule here will cause the WebClientAuthorizationModule to execute and crash on that line because the context is incorrect.

To quickly verify my suspicions you can do the following:

Global.asax - update to inherit from a Global class
<%@ Application Language="C#" Inherits="Global" %>


App_Code\Global.asax.cs - create the following class and add the applicable namespaces
using Microsoft.Practices.CompositeWeb;
using Microsoft.Practices.CompositeWeb.ObjectBuilder;
using Microsoft.Practices.ObjectBuilder;
 
/// <summary>
/// Summary description for Global
/// </summary>
 
public class Global : WebClientApplication
{
    public Global()
    {
    }
 
    protected override void AddBuilderStrategies(IBuilder<WCSFBuilderStage> builder)
    {
        base.AddBuilderStrategies(builder);
    }
 
}

Place a breakpoint on the line base.AddBuilderStrategies(builder); and run your "Main Web Project" - you will get a break.

Run your subweb - it won't break here - it doesn't find a Global.asax file...








Apr 28, 2008 at 9:55 PM
Hi Bill ,
Thanks for your explainations.
I got your point But I have added those subweb Projects using GuidancePackage for Web Client Service Factory only

I mean the Options Avaliable on Right click of Main Web Project

All SubWeb Projects are having .web extension. As Per your description I verified that only Main Web Project has Golbal.asax File the rest of are not having the Global.asax.

What should be the possible solutions to this?

I just got confused with this WCSF stuff.

Please Explain/Guide me the right path.

I would be very much thankful to you

Thanks a lot !
Chirag
Should I add global.asax for each of them ? I dont think this is solution




BillKrat wrote:

maisuriya wrote:

Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



Based on the above error message and the following statement it would seem that you created subwebs as applications under your primary web and did not provide a Global.asax within the application. This would be consistent with the error you reported in the message thread Taking More time to Load the application because the subweb application becomes an application (not subweb), i.e., there will be no ~/Shared/Master.master in your subweb (it actually exists in your perceived parent web).

maisuriyaWhen I am runing Main Web Project It runs fine But when I want to explore or browse to any of the SubWeb Project It gives me Following Error.

To duplicate the above error in your main web simply rename your global.asax file. The IHttpModule More on HttpModule here will cause the WebClientAuthorizationModule to execute and crash on that line because the context is incorrect.

To quickly verify my suspicions you can do the following:

Global.asax - update to inherit from a Global class
<%@ Application Language="C#" Inherits="Global" %>


App_Code\Global.asax.cs - create the following class and add the applicable namespaces
using Microsoft.Practices.CompositeWeb;
using Microsoft.Practices.CompositeWeb.ObjectBuilder;
using Microsoft.Practices.ObjectBuilder;
 
/// <summary>
/// Summary description for Global
/// </summary>
 
public class Global : WebClientApplication
{
    public Global()
    {
    }
 
    protected override void AddBuilderStrategies(IBuilder<WCSFBuilderStage> builder)
    {
        base.AddBuilderStrategies(builder);
    }
 
}

Place a breakpoint on the line base.AddBuilderStrategies(builder); and run your "Main Web Project" - you will get a break.

Run your subweb - it won't break here - it doesn't find a Global.asax file...










Apr 28, 2008 at 10:28 PM


maisuriya wrote:
Should I add global.asax for each of them ? I dont think this is solution


I agree..

In light of your time constraints and being new to WCSF (as I am) my recommendation would be to create multiple "Web Client solutions" or better yet modules within your current solution (so you can share your Master Page) and stay on the "beaten path" so that it is easier to resolve issues you may run into.


May 26, 2008 at 8:52 AM
Edited May 26, 2008 at 9:28 AM
I have the same issue, but only with pre-compiled version of the WCSF web site, please advise any solution?
Thanks.

Forget about this, this self-fixed after couple of recompilations...