[Mono-bugs] [Bug 58758][Wis] New - ashx without codebehind cannot find dlls in bin/
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 20 May 2004 10:44:59 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by chris@turchin.net.
http://bugzilla.ximian.com/show_bug.cgi?id=58758
--- shadow/58758 2004-05-20 10:44:59.000000000 -0400
+++ shadow/58758.tmp.19634 2004-05-20 10:44:59.000000000 -0400
@@ -0,0 +1,142 @@
+Bug#: 58758
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details: mdk 9.1
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Sys.Web
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: chris@turchin.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: ashx without codebehind cannot find dlls in bin/
+
+a web handler implemented without codebehind yields the following browser
+message (also wrong):
+
+Server error in '/gd-gallery' application
+Cannot find '/gd-gallery/thumbnail.ashx'.
+Description: Error processing request.
+
+Error Message: HTTP 404. Cannot find '/gd-gallery/thumbnail.ashx'.
+
+and this message (apche loglevel debug) appears in err_log:
+
+
+** (/usr/lib/mono/1.0/mcs.exe:19599): WARNING **: Could not find assembly
+GDGallery, references from /tmp/46463.dll (assemblyref_index=0)
+ Major/Minor: 1,0
+ Build: 1601,28900
+ Token: (null)
+
+
+Unhandled Exception: System.NullReferenceException: A null value was found
+where an object instance was required.
+in (unmanaged) /usr/lib/libmono.so.0(mono_assembly_open+0xde) [0x400def2e]
+in (unmanaged) /usr/lib/libmono.so.0 [0x400d0c89]
+in <0x000d1> Mono.CSharp.Driver:LoadAssembly (string,bool)
+in <0x0009f> Mono.CSharp.Driver:LoadReferences ()
+in <0x006ac> Mono.CSharp.Driver:MainDriver (string[])
+in <0x00012> Mono.CSharp.Driver:Main (string[])
+
+the same code when compiled as a codebehind in a dll works fine. here is
+the code below, interestingly, it is not the Ntx.GD reference but rather
+its own namespace GDGallery that is causing the problem... and, yes, the
+assembly is there and other pages are working fine...
+
+mono from cvs two days ago. xsp from cvs and mod_mono from cvs before
+the virtual hosts patch...
+
+code:
+
+<%@ WebHandler Language="c#" Class="GDGallery.GDResizer" %>
+using System;
+using System.IO;
+using System.Web;
+using System.Web.SessionState;
+using Ntx.GD;
+
+namespace GDGallery
+{
+ public class GDResizer : IHttpHandler, IRequiresSessionState
+ {
+
+ public void ProcessRequest (HttpContext c)
+ {
+
+ string cacheDir = "/data/web/gd-gallery/cache/";
+ string fn = "";
+ string cacheFile = "";
+ string fmt = "";
+ GDObjectType otype = GDObjectType.Thumbnail;
+ FileInfo file = null;
+
+ if (c.Request["fn"] == null)
+ throw new ApplicationException("Pass the right parameters!");
+
+ fn = Convert.ToString(c.Session["CurrentDir"]) +
+Path.DirectorySeparatorChar + c.Request["fn"];
+ file = new FileInfo(fn);
+
+ if (file==null)
+ throw new Exception(fn);
+
+ if (c.Request["fmt"] != null)
+ {
+ fmt = c.Request["fmt"] ;
+ if (Enum.IsDefined(typeof(GDObjectType), fmt))
+ otype = (GDObjectType)Enum.Parse(typeof(GDObjectType),fmt);
+ }
+
+ cacheFile = otype.ToString() + "_" + file.FullName.Replace("/","_");
+
+ if (File.Exists(cacheDir + cacheFile))
+ {
+ c.Response.ContentType = "image/jpeg";
+ c.Response.Redirect("cache/" + cacheFile);
+ }
+ else
+ {
+ if (!(file.Extension.ToLower() == ".jpg"))
+ throw new ApplicationException("Wrong File Type Exception");
+
+ GD image = new GD( GD.FileType.Jpeg, file.FullName );
+
+ double ratio = 1.0;
+ double h = image.Height;
+ double w = image.Width;
+ double max = Convert.ToDouble(otype);
+
+ if (w<=max&&h<=max)
+ ratio = 1.0;
+ else if (h>=w)
+ ratio = ((int)otype)/h;
+ else
+ ratio = ((int)otype)/w;
+
+ h = h * ratio;
+ w = w * ratio;
+
+ image.Resize((int)w,(int)h);
+
+ c.Response.ContentType = "image/jpeg";
+ image.Save(GD.FileType.Jpeg,c.Response.OutputStream,50);
+ image.Save(GD.FileType.Jpeg,cacheDir + cacheFile,50);
+
+ image.Dispose();
+ image = null;
+ GC.Collect();
+ }
+ }
+
+ public bool IsReusable
+ {
+ get { return true; }
+ }
+ }
+}