Another "Invalid type owner for DynamicMethod" problem

Topics: Web Client Software Factory, UIP Application Block discussion, User Forum
Jul 16, 2008 at 1:42 AM
I hope you guys can help...

Here is the scenario...

I have a WCSF web site with several modules. I am using the approach used in the Order Management sample implementation where user controls (named "Parts" in this implementation) are used.

I have a "Members" module with a default view. The view loads member information and displays it when the Default.aspx page is loaded.

I then created an "Appointments" module. This module has a default view to setup new appointments, and has two user control view ("Parts" as used in Order Management sample implementation) to display Appointment Details and to allow appointment data manipulation.

These user controls are used in the "Members" module default view (they are actually used in the Default.aspx page that implements the default view of course).

When I run the web site, I can see the default view, and the Appointments default view (which does not use the appointment "parts" at this time), but when I try to load the member module's default view (which uses the appointment "parts") I get the Exception "Invalid type owner for DynamicMethod" of type "System.ArugumentException".

I've noticed that none of the other pages load the Microsoft.Practices.CompositeWeb.Web.UI.UserControl class (which makes sense since only ASP.NET controls are being used). The call that initiates the process is the 'WebClientApplication.BuildItemWithCurrentContext(this);" method call.

The exception is being raised in the Microsoft.Practices.CompositeWeb.ObjectBuilder.BuildPlan.DynamicMethodPlan.DynamicMethodPlanBuilderPolicy class in the "public IBuildPlan CreatePlan(Type typeToBuild, string idToBuild)" method.

I then added the controls to the Appointment module's default view and I don't get the Exception, so it seems that the problem has to do when a view in one module uses user controls from another module.

Any help with this will be greatly appreciated.

Jul 16, 2008 at 6:12 PM
Edited Jul 16, 2008 at 6:12 PM
In the Order Management RI, we put shared user controls in thier own module, and then each module that used the user control took a dependency on the shared module.  It sounds like you may not have set the moduel dependecies up. Maybe...

This type of error is usually caused when the container cannot find a concrete type to create.  Are you using interfaces for dependencies and not setting a concrete type (via the Type Mapping functionality) in all the modules that use the interface?  Also, keep in mind that each Module has its own container, "inheriting" the settings from the root (Shell) module.  If you setup IFoo resolves to MyFoo in Module A, you also need to set it up in Module B (or in the root module).

I hope that is not too confusing and helps you out a bit.

Michael Puleio -- patterns & practices  
Jul 17, 2008 at 4:43 AM

Thanks for your response.

I did what you suggested and it worked.

I was setting the type mapping in the Appointments module's module initializer. I added the same line of code in the members module's module initializer and it works prefectly.

Thanks for the help.

Jorge Castellanos
Jul 17, 2008 at 10:03 PM

Not a problem....

There are some things in an application, that if they are used in most of your modules, it is best to configure in the Shell module.  For example, if you have a ITraceLogger, or IPerfcounterProvider, or some other cross cutting concern that almost everything uses, you can save yourself some headaches and configure it once.  If necessary, you can even override the config in another module.  The simple example is that if you have ITraceLogger configured in the Shell as NoramlTraceLogger, but you have a module B that is causing grief, you can override the config for module B to use the VerboseTraceLogger.  It is a useful feature that we don't talk about too much.

Michael Puleio -- patterns & practices  


Aug 13, 2008 at 3:10 PM
We have a problem with using Logging application block with WCSF.We would like to control the logging details at the module level even though it has been defined at the website level.

Specifically we have this problem

When there is Logging logic is implemented in both Website Web.Config file and module web.config, we found following observations :
a. It does not allow to have similar TraceListener,Formatter,Filter and Category name for the both config files.
b. When I try to create different TraceListener,Formatter,Filter and Category, I got an runtikme error saying that "The [Assembler] attribute is not set in the configuration object type  Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LogFilterData. ". This shows that, we can have Logging config data shouls be in either module level or website level.

Our inferences:
c. When there is no logging data in Modules and log data available in website level, then it works as per Module config file as expexted.
d. When there is log data for webite sconfig file and no logging data in molule config file, then it works as per wesite config file as expexted.