none
Custom control as assembly in medium trust server; any workarounds? RRS feed

  • Question

  •  I was using tag-mapping to enable a 'hidden html Input' to script its text, so it can carry XML strings. My shared server did not like tag-mapping; so, I changed it to a custom control. Visual Studio 2005 did not like my custom control class in the /App_Code so I made an assembly from it and put it in the /Bin directory. Now, shared server (medium trust permissions) does not like my .dll assembly in the /bin folder and the error I can read using Internet Explorer is:
    <<<<
    Parser Error:
    ......
    Assembly Load Trace: The following information can be helpful to determine why the assembly 'MyAppCode' could not be loaded.

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
     >>>>

    This has to do with medium trust permissions and not being able to use full trust assemblies. What workaround works for me? These are the possibilities I found out, but not sure which one works, I prefer a workaround that does not need help from hosting company, since they would charge $120/hr to help:
    1) put the assembly in GAC instead of /Bin: hosting company kinda said they would not do this, and if they do they will charge
    2) making my own permission policy file: would work only if the server belonged to me, or was set to full trust in the first place
    3) change permission for files in /Bin directory to allow execution: probably not going to work
    4) I have an extra cgi folder under top directory ; maybe I can use /cgi instead of /web/Bin ?!
    5) I read about a very very similar, but not sure if exactly the same permission problem. It said Web-Applications do not have this permission problem, Nor do web-Sites precompiled in full trust, then deployed in partial trust environments. Should I try to publish precompiled website instead of FTP-ing my files?
    6) having custom control class in App-Code throws some errors; should I catch the errors and throw them away?!
    7) If nothing else works, make development environment medium trust, too; to get the same error messages while debugging.
    8) change server?

    Friday, December 5, 2008 1:59 AM

Answers

  • I don't understand why you will move code from VS to a hosting server without making sure  your code runs in medium trust.  The full trust and GAC code means you must host it in house and not a hosting place.  Here is the CLR Debugger run it with your code in IIS and you will see what needs to be changed for your code to build.  You must also know that reflections permissions in Asp.net require full trust by default with work around solutions.  So build your application without the custom control and go from there so you can find and resolve the permissions issue.


    http://support.microsoft.com/default.aspx/kb/893657


    Asp.net MVP, MCPD Web C#, MCTS TFS, MCITP BI and DBA
    • Marked as answer by Pitiko2 Saturday, December 6, 2008 5:33 AM
    Saturday, December 6, 2008 12:42 AM
    Moderator