The page Y.ascx cannot use the user control X.ascx
Asked Answered
S

1

2

I recently got the following error in my web application.

The page 'ControlName.ascx' cannot use the user control 'OtherControl.ascx', because it is registered in web.config and lives in the same directory as the page.

Whilst I was able to fix the error by moving the control and registering it in the page I'm curious as to why this raises an error.

This is apparently by design as design as described here (3/4 down in yellow block) but my question is why? What problem might you face by registering the control in the Web.Config and placing it the same directory?

Sandfly answered 18/4, 2012 at 14:32 Comment(0)
W
2

Maybe it is a matter of dynamic compilation. By default the "batch" attribute of the "compilation" element in your web.config is true. Something like this :

<compilation defaultLanguage="c#" debug="false" batch="true" targetFramework="4.0" />

With batch="true", whenever a control has to be compiled in a directory, the server compiles all controls (everything?) in its directory.

I would say that web.config declared controls are not compiled the same way as other controls (in another dll, another directory ?) So, mixing web.config declared controls and other controls in the same directory, some referencing the others would result in duplicate compilation and dll conflicts.

Washerwoman answered 18/4, 2012 at 15:34 Comment(1)
Interesting I'll take a look at the Batch attribute.Sandfly

© 2022 - 2024 — McMap. All rights reserved.