[Mono-dev] Error in Mono but not on IIS: A null reference or invalid value was found [GDI+ status: InvalidParameter]

Stifu stifu at free.fr
Mon Oct 18 17:45:25 EDT 2010


This may not help, but these 2 bug reports seem related:

https://bugzilla.novell.com/show_bug.cgi?id=510805
https://bugzilla.novell.com/show_bug.cgi?id=569940

Maybe the image you tested had some issues that .NET tolerates? You could
try with other images to make sure.


urbs44 wrote:
> 
> Hello Mono world!  I am having a difficult time trying to figure out a way
> to create an image cropping tool using c# and JQuery's Jcrop plug-in.  I
> can get the code to work perfectly in plain old .net, but mono gives me
> the following error:
> 
> A null reference or invalid value was found [GDI+ status:
> InvalidParameter]
> 
> Description: HTTP 500. Error processing request.
> 
> Stack Trace:
> 
> System.ArgumentException: A null reference or invalid value was found
> [GDI+ status: InvalidParameter]
>   at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in
> <filename unknown>:0
>   at System.Drawing.Bitmap.SetResolution (Single xDpi, Single yDpi)
> [0x00000] in <filename unknown>:0
>   at (wrapper remoting-invoke-with-check)
> System.Drawing.Bitmap:SetResolution (single,single)
>   at Fankit.ProfilePictures.btnCrop_Click (System.Object sender,
> System.EventArgs e) [0x00000] in <filename unknown>:0
>   at System.Web.UI.WebControls.Button.OnClick (System.EventArgs e)
> [0x00000] in <filename unknown>:0
>   at System.Web.UI.WebControls.Button.RaisePostBackEvent (System.String
> eventArgument) [0x00000] in <filename unknown>:0
>   at
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
> (System.String eventArgument) [0x00000] in <filename unknown>:0
>   at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler
> sourceControl, System.String eventArgument) [0x00000] in <filename
> unknown>:0
>   at System.Web.UI.Page.RaisePostBackEvents () [0x00000] in <filename
> unknown>:0
>   at System.Web.UI.Page.ProcessRaiseEvents () [0x00000] in <filename
> unknown>:0
>   at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename
> unknown>:0
>   at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context)
> [0x00000] in <filename unknown>:0
> 
> Here is the code behind:
> 
> protected void btnCrop_Click(object sender, EventArgs e)
>         {
>             string ImageName = CurrentImage.Value;
>             string ImageNameOnly =
> CurrentImage.Value.Substring(CurrentImage.Value.LastIndexOf("/") + 1,
> CurrentImage.Value.Length - CurrentImage.Value.LastIndexOf("/") - 1);
>             int w = Convert.ToInt32(W.Value);
>             int h = Convert.ToInt32(H.Value);
>             int x = Convert.ToInt32(X.Value);
>             int y = Convert.ToInt32(Y.Value);
> 
>             string originalFile = Server.MapPath("~/cms/uploads/" +
> ImageNameOnly);
> 
>             using (var photo =
> System.Drawing.Image.FromFile(Server.MapPath("~/cms/uploads/" +
> ImageNameOnly)))
> 
>             using (var result = new Bitmap(w, h, photo.PixelFormat))
>             {
>                 result.SetResolution(photo.HorizontalResolution,
> photo.VerticalResolution);
> 
>                 using (var g = Graphics.FromImage(result))
>                 {
>                     g.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> 
>                     g.DrawImage(photo, new Rectangle(0, 0, 100, 100),
>                          new Rectangle(x, y, w, h),
>                          GraphicsUnit.Pixel);
> 
>                     photo.Dispose();
> 
>                     //result.Save(sp + "crop-" + ImageNameOnly);
>                     imgCropped.ImageUrl = "/cms/uploads/crop-" +
> ImageNameOnly;
> 
>                 }
> 
>             }
>          }
> 
> 
> It seems like this line is the root of the problem: using (var photo =
> System.Drawing.Image.FromFile(Server.MapPath("~/cms/uploads/" +
> ImageNameOnly)))
> 
> Is there a way around this error??
> 
> --
> Matthew Urbano | Web Developer
> Trailer Park Interactive
> 6922 Hollywood Blvd., 7th floor
> Hollywood, CA  90028
> T: 310-845-3021
> M: 305-790-1805
> matthew.urbano at trailerpark.com<mailto:matthew.urbano at trailerpark.com>
> 
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 

-- 
View this message in context: http://mono.1490590.n4.nabble.com/Error-in-Mono-but-not-on-IIS-A-null-reference-or-invalid-value-was-found-GDI-status-InvalidParameter-tp3000862p3001149.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list