Value cannot be null. problem in the WCSFExtensions

May 20, 2007 at 9:57 AM
Hi all,
I'm trying to run a WCSF project, I always get the fault :

[ArgumentNullException: Value cannot be null.
Parameter name: item]
Microsoft.Practices.ObjectBuilder.WCSFExtensions.WCSFBuilderBase`1.TearDown(IReadWriteLocator locator, TItem item) in C:\Documents and Settings\wasimf\My Documents\Visual Studio 2005\Projects\WCSF Source\Blocks\ObjectBuilder.WCSFExtensions\Source\ObjectBuilder.WCSFExtensions\WCSFBuilderBase.cs:120
Microsoft.Practices.CompositeWeb.WebClientApplication.InnerPostRequestHandlerExecute(IHttpContext context) in C:\Documents and Settings\wasimf\My Documents\Visual Studio 2005\Projects\WCSF Source\Blocks\CompositeWeb\Source\CompositeWeb\WebClientApplication.cs:110
Microsoft.Practices.CompositeWeb.WebClientApplication.Application_PostRequestHandlerExecute(Object sender, EventArgs e) in C:\Documents and Settings\wasimf\My Documents\Visual Studio 2005\Projects\WCSF Source\Blocks\CompositeWeb\Source\CompositeWeb\WebClientApplication.cs:75
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

I debuged thw WCSFBuilderBase file and found the problem with the method :
public TItem TearDown<TItem>(IReadWriteLocator locator, TItem item)
{
if (typeof(TItem).IsValueType == false && item == null)
throw new ArgumentNullException("item");
return DoTearDown<TItem>(locator, item);
}


What can be the problem.

Thanks in advanced...
May 20, 2007 at 1:02 PM
This sounds very familiair. Did you happen to install Orcas Beta 1 next to VS2005? Because that caused the exact same problems. I had to reintall my laptop to get everything running properly again.
May 22, 2007 at 2:15 AM
I have this problem too.

As a workaround (instead of reinstalling) you can make the following change in WebClientApplication.cs on line 107:

if (HttpRequestHelper.IsHandledByPageHandlerFactory(context.Request.Url.ToString()) &&
context.Handler != null)

This is obviously not ideal but will get this working in Orcas Beta 1 until we have the official fix.
Jul 27, 2007 at 8:54 PM
It is easier to subclass the WebClientApplication and point your Global.asax file to the subclassed application and just override the existing behavior with the above suggested changes. This way you won't have to deal with changing all references to CompositeWeb assemblies.
Aug 22, 2007 at 4:26 PM
Hi katokay,
Can you be more specific? Or upload your project?

Thanks, Pini.



katokay wrote:
It is easier to subclass the WebClientApplication and point your Global.asax file to the subclassed application and just override the existing behavior with the above suggested changes. This way you won't have to deal with changing all references to CompositeWeb assemblies.

Aug 28, 2007 at 10:55 PM
I too have this problem and I dont have orcas beta 1 but do have .net 3.5 installed.

I found this blog post from someone, JB, that found and fixed the problem:
http://www.turtle.net.nz/blog/post/CompositeWebBlockAndOrcasBeta1

Hope it works for you too,

Jay
Aug 30, 2007 at 9:10 PM
Edited Aug 30, 2007 at 9:11 PM


aconsolati wrote:
I have this problem too.

As a workaround (instead of reinstalling) you can make the following change in WebClientApplication.cs on line 107:

if (HttpRequestHelper.IsHandledByPageHandlerFactory(context.Request.Url.ToString()) &&
context.Handler != null)

This is obviously not ideal but will get this working in Orcas Beta 1 until we have the official fix.


I use VS2005 sp1 on Vista Ultimate. I changed this code, CompositeWeb project in WebClientApplication.cs. Save and rebuild this project. And Microsoft.Practices.CompositeWeb.dll replace in C:\Program Files\Microsoft Web Client Factory\WCSF Guidance Package and C:\Program Files\Microsoft Web Client Factory\Microsoft Practices Library. Now build my WebClientApplication1 and were 3 Errors.

Error 1 The type 'Microsoft.Practices.CompositeWeb.Interfaces.IAuthorizationService' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.CompositeWeb, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. C:\Users\xinberg\Documents\Visual Studio 2005\Projects\WebClientApplication1\Modules\Shell\ShellModuleInitializer.cs 46 13 Shell

Error 2 The type 'Microsoft.Practices.CompositeWeb.EnterpriseLibrary.Services.EnterpriseLibraryAuthorizationService' must be convertible to 'Microsoft.Practices.CompositeWeb.Interfaces.IAuthorizationService' in order to use it as parameter 'TService' in the generic type or method 'Microsoft.Practices.CompositeWeb.Interfaces.IServiceCollection.AddNew<TService,TRegisterAs>()' C:\Users\xinberg\Documents\Visual Studio 2005\Projects\WebClientApplication1\Modules\Shell\ShellModuleInitializer.cs 46 13 Shell

Error 3 Metadata file 'C:\Users\xinberg\Documents\Visual Studio 2005\Projects\WebClientApplication1\Modules\Shell\bin\Debug\Shell.dll' could not be found DevelopmentWebsite

ShellModuleInitializer.cs in this code:

protected virtual void AddGlobalServices(IServiceCollection globalServices)
{
globalServices.AddNew<EnterpriseLibraryAuthorizationService, IAuthorizationService>();
_siteMapBuilderService = globalServices.AddNew<SiteMapBuilderService, ISiteMapBuilderService>();
}

Please help!
Aug 31, 2007 at 4:17 AM
Hi, the problem there is that some assemblies has references to the signed version of the Microsoft.Practices.CompositeWeb assembly but when you compiling the block you produce an unsigned version of them.

To solve this, also copy the assemblies Microsoft.Practices.CompositeWeb.EnterpriseLibrary.dll and Microsoft.Practices.ObjectBuilder.WCSFExtensions.dll you just built to the Microsoft Practices Library folder.

Let me know if this helps,

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib
Aug 31, 2007 at 6:49 PM


ejadib wrote:
Hi, the problem there is that some assemblies has references to the signed version of the Microsoft.Practices.CompositeWeb assembly but when you compiling the block you produce an unsigned version of them.

To solve this, also copy the assemblies Microsoft.Practices.CompositeWeb.EnterpriseLibrary.dll and Microsoft.Practices.ObjectBuilder.WCSFExtensions.dll you just built to the Microsoft Practices Library folder.

Let me know if this helps,

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib



I try this, but don't work or I couldn't this. Can you explain this, detailed and step by step.
Thanks a lot.
Sep 27, 2007 at 2:47 PM
Step By Step:
1. Open <SourceDir>\Microsoft Web Client Factory\Source Code\Blocks\CompositeWeb\CompositeWeb.sln
2. If you want to use Enterprise Library 3.1 dlls then copy all contents from <install-dir>\Microsoft Enterprise Library 3.1 - May 2007\Bin to <SourceDir>\Microsoft Web Client Factory\Source Code\Blocks\EnterpriseLibrary
3. Rebuild the solution.
4. <SourceDir>\Microsoft Web Client Factory\Source Code\Blocks\CompositeWeb\Source\CompositeWeb.EnterpriseLibrary\bin\Debug will contain all the compiled dlls. Copy All DLLs from this directory to your WCSF solution's Library folder. Override when asked.
5. Rebuild your WCSF solution.
Sep 30, 2007 at 2:16 PM
Thanks a lot. It's work!

hsc4m wrote:
Step By Step:
1. Open <SourceDir>\Microsoft Web Client Factory\Source Code\Blocks\CompositeWeb\CompositeWeb.sln
2. If you want to use Enterprise Library 3.1 dlls then copy all contents from <install-dir>\Microsoft Enterprise Library 3.1 - May 2007\Bin to <SourceDir>\Microsoft Web Client Factory\Source Code\Blocks\EnterpriseLibrary
3. Rebuild the solution.
4. <SourceDir>\Microsoft Web Client Factory\Source Code\Blocks\CompositeWeb\Source\CompositeWeb.EnterpriseLibrary\bin\Debug will contain all the compiled dlls. Copy All DLLs from this directory to your WCSF solution's Library folder. Override when asked.
5. Rebuild your WCSF solution.

Oct 22, 2007 at 5:33 PM
Edited Oct 22, 2007 at 5:37 PM
I built the source code for WCFS and got the assembly reference problem too. No matter what I tried to get the 3 assemblies

Microsoft.Practices.CompositeWeb.dll
Microsoft.Practices.CompositeWeb.EnterpriseLibrary.dll
Microsoft.Practices.ObjectBuilder.WCSFExtensions.dll

to work together, there was always the same reference problem with Microsoft.Practices.CompositeWeb.

Eventually,
I changed the versions of the above assemblies in CompositeWeb solution to 1.1.0.1,
Removed the 1.1.0.0 assemblies referenced in the GlobalBank Shell project and
referenced to 1.1.0.1.
The reference problem was over.

After 4 days of wrestling with WCSF I finally got the application default.aspx to show up in the browser.
Nov 12, 2007 at 6:34 PM
Hi,

If you don't want to modify/rebuild the WCSF (katokay's solution explained a bit more detailed) is to create a new subclass of the webapplication like this:

namespace MyNamespace
{
public class MyWebClientApplication : Microsoft.Practices.CompositeWeb.WebClientApplication
{

protected override void Application_PostRequestHandlerExecute(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
InnerPostRequestHandlerExecute(new Microsoft.Practices.CompositeWeb.Web.HttpContext(context));
}

protected new void InnerPostRequestHandlerExecute(IHttpContext context)
{
if (HttpRequestHelper.IsHandledByPageHandlerFactory(context.Request.Url.ToString()) && context.Handler != null)
{
ICompositionContainer moduleContainer = GetModuleContainer(context);
PageBuilder.TearDown(moduleContainer.Locator, context.Handler);
}

if (context.Handler is Page)
{
PostPageExecute(context.Handler as Page);
}
}
}
}

then modify the global.asax to look like this:

<%@ Application Language="C#" Inherits="MyNamespace.MyWebClientApplication " %>

Best Regards,

Wiebe Tijsma
Nov 30, 2007 at 4:33 PM
This work-around works like a charm.
Thanks a lot




wtijsma wrote:
Hi,

If you don't want to modify/rebuild the WCSF (katokay's solution explained a bit more detailed) is to create a new subclass of the webapplication like this:

namespace MyNamespace
{
public class MyWebClientApplication : Microsoft.Practices.CompositeWeb.WebClientApplication
{

protected override void Application_PostRequestHandlerExecute(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
InnerPostRequestHandlerExecute(new Microsoft.Practices.CompositeWeb.Web.HttpContext(context));
}

protected new void InnerPostRequestHandlerExecute(IHttpContext context)
{
if (HttpRequestHelper.IsHandledByPageHandlerFactory(context.Request.Url.ToString()) && context.Handler != null)
{
ICompositionContainer moduleContainer = GetModuleContainer(context);
PageBuilder.TearDown(moduleContainer.Locator, context.Handler);
}

if (context.Handler is Page)
{
PostPageExecute(context.Handler as Page);
}
}
}
}

then modify the global.asax to look like this:

<%@ Application Language="C#" Inherits="MyNamespace.MyWebClientApplication " %>

Best Regards,

Wiebe Tijsma