Invalid type owner for DynamicMethod

Oct 2, 2008 at 8:50 AM
Hi,

I hope can get some help from here.

I am trying to use a user control(with presenter)  created in an business module within Shell business module.

Everytime when I try to open the view that using the user control in Shell module, the "Invalid type owner for DynamicMethod" exception is generated.

What steps I need to follow to configure the depenedncies bewtween Shell module and the module holding the user control to get it working?

Thanks

Developer
Oct 2, 2008 at 1:34 PM

Hi

 

The easiest way to overcome this issue when you use shared User Controls along different modules, is that each module that uses this User Control must have a dependency on the shared module in its web.config file. Check the Order Management RI where the shared User Controls were put together in the SharedUserControls module, and then each Module that used some of these User Controls took a dependency on the shared module:

 

<compositeWeb>

<modules>

<module name="Orders" assemblyName="OrderManagement.Orders" virtualPath="~/Orders">

<dependencies>

<dependency module="Shell" />

<dependency module="SharedUserControls" />

</dependencies>

...

</module>

</modules>

...

</compositeWeb>

 

Usually this kind of error is caused when the Container cannot find a concrete type to instantiate.  Are you using interfaces for dependencies and not mapping a concrete type to them (via the RegisterTypeMapping method of the container) in all the modules that use the interface?

Take into account that each module has its own container so if you set a Type Mapping in the context of Module1, you must also set up the same mapping in the context of Module B (or in the Shell module – which is the root).

In this particular case, the user control might be using a mapping that has only been defined in the business module, but because now it’s being build up in the context of the Shell, this mapping may not be found by the Shell container.

 

Please let me know if this helps.

 

Mariano Converti

http://blogs.southworks.net/mconverti
Oct 2, 2008 at 2:03 PM
Hi Mariano,

Thanks for your reply. I am using the interfaces for dependencies.

As I am trying to use the usercontrol in Shell module, how should I configure the dependency?

Regards,

Yu
Developer
Oct 2, 2008 at 5:40 PM

Hi Yu,

 

You should specify the module dependency in your Root Web.config of your Web Site:

 

<compositeWeb>

<modules>

<module name="Shell" assemblyName="OrderManagement.Shell" virtualPath="~/">

<dependencies>

<dependency module="SharedUserControls"/>

</dependencies>

</module>

<module name="SharedUserControls" assemblyName="OrderManagement.SharedUserControls" virtualPath="~/SharedUserControls" />

</modules>

...

</compositeWeb>

 

You must take into account that you should not use services, commonly loaded in the Shell in the module, where you have the shared users controls. This is because you are changing the loading order of the modules. For example: If you are using a Business module to contain your users controls, you should delete the call to the RegisterSiteMapInformation method in the Load method.

 

Please let me know if this helps.

 

Mariano Converti

http://blogs.southworks.net/mconverti

Oct 3, 2008 at 8:44 AM
Thanks Mariano.

The problem has been solved. I put the UserControl in a foundation module like the OrderManagementRI does.