<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blog.aptwebsolutions.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>De-Velopment : debugging</title><link>http://blog.aptwebsolutions.com/archive/tags/debugging/default.aspx</link><description>Tags: debugging</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>Debugging and Deploying ASP.NET applications in a hosted environment: tips and tricks</title><link>http://blog.aptwebsolutions.com/archive/2007/02/22/debugging-and-deploying-asp-net-applications-in-a-hosted-environment-tips-and-tricks.aspx</link><pubDate>Thu, 22 Feb 2007 05:49:00 GMT</pubDate><guid isPermaLink="false">2252f0e1-0c16-432a-8283-32602c20dbfa:7</guid><dc:creator>admin</dc:creator><slash:comments>0</slash:comments><comments>http://blog.aptwebsolutions.com/comments/7.aspx</comments><wfw:commentRss>http://blog.aptwebsolutions.com/commentrss.aspx?PostID=7</wfw:commentRss><description>&lt;P&gt;Deploying a production application to a (cheap)&amp;nbsp;hosted envirionment can be a challenge. You are usually stuck using helm or some sort of control panel to manage your site.&amp;nbsp;Things like&amp;nbsp;partial trust and lack of log access&amp;nbsp;are very limiting. It's easy to get frustrated quickly.&amp;nbsp;I recently ran into a few walls when I deployed 2 production applications to my current&amp;nbsp;host: ASPnix. I'm going to lay out some of the problems that I ran into. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;deployment retail="true" /&amp;gt;&lt;BR&gt;&lt;/STRONG&gt;This is a setting at the machine.config level that is new to asp.net 2.0. It disables the trace output in pages, turns off the ability to show error messages remotely, and disables &amp;lt;compilation debug="true" /&amp;gt;. If your host has&amp;nbsp;retail="true" and you enable debug compilation your site will error and you wont be able to tell why. You will see the normal "turn CustomErrors to Off to see the details of this error....etc" message&amp;nbsp;only you can't turn CustomErrors off. You will pull your hair out. What's even worse is if you have some sort of catch all logging for errors in global.asax the error will not get logged. So...make sure to set debug="false" before you deploy. &lt;/P&gt;
&lt;P&gt;While I was troubleshooting my logging (see below) I added a quick and dirty way to see errors:&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:872f5268-a570-4a87-bbec-f05d6b2654cf style="PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;FLOAT:none;PADDING-BOTTOM:0px;MARGIN:0px;PADDING-TOP:0px;"&gt;Global.asax&lt;PRE style="WIDTH:100%;"&gt;&lt;DIV&gt;&lt;SPAN style="COLOR:#000000;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; Application_Error(&lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; sender, EventArgs e)
    {
        Exception ex &lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; Server.GetLastError().GetBaseException();
        Context.Cache[&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;LastError&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;] &lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; ex;
    }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:7f2c36e2-c5ae-40b4-a325-cae12131f016 style="PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;FLOAT:none;PADDING-BOTTOM:0px;MARGIN:0px;PADDING-TOP:0px;"&gt;ViewError.cs&lt;PRE style="WIDTH:100%;"&gt;&lt;DIV&gt;&lt;SPAN style="COLOR:#000000;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; Page_Load(&lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; sender, EventArgs e)
    {

        &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;(Cache[&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;LastError&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;] &lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;!=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;)
        {
            Exception ex &lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; Cache[&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;LastError&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;] &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; Exception;
            Response.Write(ex.ToString());
        }
            
    }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Partial Trust&lt;BR&gt;&lt;/STRONG&gt;The majority of asp.net hosts today will have &amp;lt;trust level="Medium" /&amp;gt;. ASPnix uses medium trust with a few exceptions that they have set (at least thats my understanding). You should do your homework here. It can be one of those major things that come back to bite you. You code an app that uses some nice 3rd party library only to find out it doesn't work when you deploy to your host.&amp;nbsp;Partial trust&amp;nbsp;prevents you from doing things like making external web service calls, pulling external rss feeds, using reflection,&amp;nbsp;calling&amp;nbsp; certain code&amp;nbsp;or performing some file access. Strongly named assemblies cannot be referenced from a partial trust environment unless they have the&amp;nbsp;AllowPartiallyTrustedCallersAttribute. It is helpful to set the trust level of the app to medium on your development box. You will need to add &amp;lt;trust level="Medium"&amp;gt; under &amp;lt;system.web&amp;gt;. You should be able to see what is throwing the&amp;nbsp;trust exception when you set the level to medium.&amp;nbsp;Make sure you remove it before you deploy or you will get an error even if it's set to medium.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran into some specific partial trust problems. The PayPal Controls assembly does not allow partially trusted callers even though the area I was trying to use just outputs glorifed links. I ended up iframing a basic html page that contained the buyitnow buttons. My other major hurdle was the Enterprise Library 2.0. It does not allow partial trust callers either. Fortunately there is a patch available. It's been a while since I did this but I believe these are the basic steps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Get the patch from gotdotnet. 
&lt;LI&gt;Copy the patch to your Enterprise Library 2.0 directory. 
&lt;LI&gt;Build the library. 
&lt;LI&gt;Run the batch files that build and copy each dll to the parent bin directory. 
&lt;LI&gt;Add requirePermission="false"&amp;nbsp;to each section like so:&amp;nbsp;&amp;lt;section name="loggingConfiguration"... requirePermission="false" /&amp;gt; 
&lt;LI&gt;If you have trouble consult this excellent article: &lt;A href="http://www.devx.com/dotnet/Article/32951" target=_blank&gt;Using Enterprise Library in ASP.NET 2.0 Partial Trust Mode&lt;/A&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blog.aptwebsolutions.com/aggbug.aspx?PostID=7" width="1" height="1"&gt;</description><category domain="http://blog.aptwebsolutions.com/archive/tags/debugging/default.aspx">debugging</category><category domain="http://blog.aptwebsolutions.com/archive/tags/deployment/default.aspx">deployment</category></item></channel></rss>