AjaxControltoolkit , ASP.NET 4.0, Seguridad y tagPrefix de Controles

461 views
Skip to first unread message

Kiquenet

unread,
Apr 17, 2012, 2:47:16鈥疉M4/17/12
to altnet-...@googlegroups.com
Hola,

estoy migrando una aplicaci贸n asp.net de .NEt 3.5-vs2008 a .net 4.0-vs2010, y ahora obtengo errores de "security transparency rules".
La aplicaci贸n usa AjaxControltoolkit entre otras (NHibernate 3.2, Ent Lib 5, Unity 2.1, etc)

El error est谩 relacionado con el ScriptManager:

L铆nea 41:     <form id="form1" runat="server">
L铆nea 42:     <asp:ScriptManager runat="server" EnablePartialRendering="true" ID="smMain" EnableScriptGlobalization="true"

[MethodAccessException: Error al intentar obtener acceso al m茅todo System.Management.Instrumentation.InstrumentedAttribute..ctor(System.String) debido a una infracci贸n de las reglas de transparencia de seguridad.]
   System.RuntimeMethodHandle.CheckLinktimeDemands(IRuntimeMethodInfo method, RuntimeModule module, Boolean isDecoratedTargetSecurityTransparent) +0
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +482
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
   System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +33
   System.Web.UI.AssemblyCache.GetAjaxFrameworkAssemblyAttribute(Assembly assembly) +114
   System.Web.UI.ScriptManager.get_DefaultAjaxFrameworkAssembly() +526
   System.Web.UI.ScriptManager..ctor() +49
   ASP.nsi_master.__BuildControlsmMain() in ... OMITIDO...


Esta es la configuraci贸n inicial (el fragmento  que interesa system.web, hay un tagprefix para los controles):

 <system.web>

    ... OMITIDO ...
      <pages theme="AdaptacionGuiaCOMPANY">
        <controls>
          <add tagPrefix="COMPANYUI" namespace="COMPANY.Frk.Web.UI.WebControls" assembly="COMPANY.Frk.Web, Version=4.0.0.0, ..."/>
          <add tagPrefix="asp" namespace="System.Web.UI" ...聽    ... OMITIDO ...
        </controls>
      </pages>
    ... OMITIDO ...
</system.web>

Aqu铆 se indica la soluci贸n:

http://forums.asp.net/t/1678578.aspx

We have seen a combination of issues that might cause this:

1) The webserver has the trust level set less than "Full" at the machine web.config (ref)

2) The webserver does not have the AJAX files (System.Web.Extensions) installed into the GAC.

Solution 1:聽Set trust level to "Full" in the machine level web.config

Solution 2:聽Install AJAX files into the GAC

If refreshing resolves it - it might just be a timing issue loading the extensions. Probably if you install into the GAC it will resolve it.

AjaxControltoolkit聽 est谩 en la GAC y el error segu铆a produci茅ndose. 聽Sigo las indicaciones para establecer trust Full en el web.config de la aplicaci贸n.

Modifico el config de esta manera (atenci贸n al location):

 <location allowOverride="false" path="Default Web Site">
    <system.web>

      <securityPolicy>

        <trustLevel name="Full" policyFile="internal"/>
        
        <!--<trustLevel name="High" policyFile="web_hightrust.config"/>
          <trustLevel name="Medium" policyFile="web_mediumtrust.config"/>
          <trustLevel name="Low" policyFile="web_lowtrust.config"/>
          <trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>-->
        
      </securityPolicy>
      <trust level="Full" originUrl="" />

 ... OMITIDO ...
      <pages theme="AdaptacionGuiaCOMPANY">
        <controls>
          <add tagPrefix="COMPANYUI" namespace="COMPANY.Frk.Web.UI.WebControls" assembly="COMPANY.Frk.Web, Version=4.0.0.0, ..."/>
          <add tagPrefix="asp" namespace="System.Web.UI" ...聽    ... OMITIDO ...
        </controls>
      </pages>
    ... OMITIDO ...
</system.web> </location>

As铆 el error ya no aparece, pero al ejecutar la aplicaci贸n aparece otro error, que no encuentra la etiqueta (el prefijo) para los controles:


http://localhost:57784/Monitorizacion/B2b/FiltroBusquedaB2b.aspx
Error de servidor en la aplicaci贸n '/'.
--------------------------------------------------------------------------------

Mensaje de error del analizador: Etiqueta de servidor 'COMPANYUI:Menu' desconocida.
Error de c贸digo fuente: L铆nea 3: <asp:HyperLink ID="CtlLogOut" runat="server" EnableViewState="false" NavigateUrl="~/Public/LogOut.aspx" CssClass="logOut">&nbsp;</asp:HyperLink> L铆nea 4: <div class="taskbarLeft"> L铆nea 5: <COMPANYUI:Menu ID="CtlMenu" runat="server" MaxLevels="1" />

En el location path he probado con ~, / , . ,聽http://localhost:57784/ pero en alg煤n caso no se permite as铆 y da errores o no soluciona el error del tagprefix.

Las pruebas son en desarrollo (VS2010, Win7 64bits), con WebDev.WebServer (cassini), por tanto la url es del tipo http://localhost:57784/.


Alguna sugerencia para este problema?

Saludos y muchas gracias de antemano
 



Oscar Torres (Gmail)

unread,
Apr 18, 2012, 2:42:34鈥疨M4/18/12
to altnet-...@googlegroups.com
Hola Kiquenet,
Este error yo lo solucione reemplazando el control <asp:ScriptManagerpor el siguiente control
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePageMethods="true"
聽聽聽聽聽聽聽聽聽聽 EnableScriptGlobalization="true" EnableScriptLocalization="true" CombineScripts="false">
聽聽聽聽聽聽 </asp:ToolkitScriptManager>
Espero te solucione tu problema.
Oscar
--
Has recibido este mensaje porque est谩s suscrito al grupo "AltNet-Hispano" de Grupos de Google.
Para ver este debate en la Web, visita https://groups.google.com/d/msg/altnet-hispano/-/jNBoP0kLJGQJ.
Para publicar una entrada en este grupo, env铆a un correo electr贸nico a altnet-...@googlegroups.com.
Para anular tu suscripci贸n a este grupo, env铆a un correo electr贸nico a altnet-hispan...@googlegroups.com
Para tener acceso a m谩s opciones, visita el grupo en http://groups.google.com/group/altnet-hispano?hl=es.
Reply all
Reply to author
Forward
0 new messages