.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

A generic error occurred in GDI+

Posted By:      Posted Date: September 04, 2010    Points: 0   Category :ASP.Net
Im trying to save an image on my hosting server. Locally everything works fine, but on the hosting server I get the error: "A generic error occurred in GDI+"I've already looked at this post: http://forums.asp.net/t/975883.aspxBut im unsure how to go about changing my current code below:    Public Shared Function SaveJpeg(ByVal path As String, ByVal img As Image, ByVal quality As Long) As Boolean        If ((quality < 0) OrElse (quality > 100)) Then            Return False            Throw New ArgumentOutOfRangeException("quality must be between 0 and 100.")        End If        ' Encoder parameter for image quality        Dim qualityParam As New EncoderParameter(Encoder.Quality, quality)        ' Jpeg image codec        Dim jpegCodec As ImageCodecInfo = GetEncoderInfo("image/jpeg")        Dim encoderParams As New EncoderParameters(1)        encoderParams.Param(0) = qualityParam        Try  

View Complete Post

More Related Resource Links

A generic error occurred in GDI+.



I'm getting this error on the yellow screen and I have no idea what to do with it, or where to start:

[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +377630
NopSolutions.NopCommerce.BusinessLogic.Media.PictureManager.GetPictureUrl(Picture picture, Int32 targetSize, Boolean showDefaultPicture) in F:\Temp\Test\nopCommerce 1.60\Libraries\Nop.BusinessLogic\Media\PictureManager.cs:396
NopSolutions.NopCommerce.BusinessLogic.Media.PictureManager.GetPictureUrl(Picture picture, Int32 targetSize) in F:\Temp\Test\nopCommerce 1.60\Libraries\Nop.BusinessLogic\Media\PictureManager.cs:180
NopSolutions.NopCommerce.Web.Administration.Modules.CategoryInfoControl.BindData() in F:\Temp\Test\nopCommerce 1.60\NopCommerceStore\Administration\Modules\CategoryInfo.ascx.cs:63
NopSolutions.NopCommerce.Web.Administration.Modules.CategoryInfoControl.Page_Load(Object sender, EventArgs e) in F:\Temp\Test\nopCommerce 1.60\NopCommerceStore\Administration\Modules\CategoryInfo.ascx.cs:99
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14

A generic error occurred in GDI+


I am getting this error at this line in my code: ImgThnail.Save(ThumbnailPath, Img.RawFormat);

Here is the entire code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;

    public static class Thumb2
        public static string createThumb(this HttpServerUtility srv, string endPath, string tempPath, int relSize)

            string ThumbnailPath = srv.MapPath("~\\Thumb\\" + endPath);
            string dimensions;
            using (System.Drawing.Image Img = System.Drawing.Image.FromFile(srv.MapPath("~\\" + tempPath))) 
                Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, relSize);
                dimensions = Img.Width.ToString() + " x " + Img.Height.ToString();
                using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height))
                    ImgThnail.Save(ThumbnailPath, Img.RawFormat);
            return dimensions;
        private static Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
            Size NewSize;
            double tempval;
            bool landscape;

A generic error occurred in GDI+. I am not sure what I am doing wrong please help!!

hello... Sorry but I get some error when I try to save an image.Here is my code If Not System.IO.Directory.Exists(DirectoryPath) Then System.IO.Directory.CreateDirectory(DirectoryPath) End If Dim FilePathName As String = DirectoryPath & "\avatar.jpg" Dim fs As New FileStream(FilePathName, FileMode.Create, FileAccess.Write) Using avatarMs As New MemoryStream(ImageBytes, 0, ImageBytes.Length) avatarMs.Write(ImageBytes, 0, ImageBytes.Length) Dim image As Image = image.FromStream(avatarMs, True)  image.Save(DirectoryPath, System.Drawing.Imaging.ImageFormat.Jpeg)'<--generic error occurred in gdi+ error appeared here End Using control.ImageUrl = DirectoryPathbasically what this code is doing is loading an an array of bytes into the memorystream(avatarMS) then converting the memory stream into an image(image) then saving the image into a folder(DirectoryPath) then displaying the image into an image control in client side... I know I am missing something here... but I don't really know what. I am not very sound in this language so if there is anything I missed out, please ask.Thanks in advanceRegards, Zephere

A generic error occurred in GDI+.


I am trying to upload image of jpeg but when i click on upload button but it gives error  like 

Thanks in Advance

A generic error occurred in GDI+.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ExternalException (0x80004005): A generic error occurred in GDI+.]
  System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +377630
  System.Drawing.Image.Save(String filename, ImageFormat format) +69

Getting generic GDI error when trying to save resized image

Getting following error:A generic error occurred in GDI+.
Any help is appreciated.
Public Sub SaveImageFile(ByVal sourceImage As Bitmap, ByVal saveImagePath As [String], ByVal maxImageWidth As Integer)
            ' Resize if source image width is greater than the max:

            If sourceImage.Width > maxImageWidth Then
                Dim bmp As Bitmap = TryCast(sourceImage, Bitmap)
                Dim newImageHeight As Integer = CInt(Math.Truncate(sourceImage.Height * (CSng(maxImageWidth) / CSng(sourceImage.Width))))
                Dim gr As Graphics = Graphics.FromImage(bmp)

                Dim bmpnew As New Bitmap(maxImageWidth, newImageHeight)
                gr.InterpolationMode = InterpolationMode.HighQualityBicubic

                gr.DrawImage(bmpnew, 0, 0, maxImageWidth, newImageHeight)

                'code to manipulate bmpNew goes here.



An operations error occurred in ActiveDirectoryMembershipProvider


Hi guys, i have an application that uses Active Directory Authentication and deployed the application several days ago without any error. Today, I got this error.please refer to the image. I find it  weird because I didn't change any code to my webconfig file since i deployed the application to the server. I've notice that it's working if it's http://localhost:50618/website/login.aspx (by opening the source file in server and debug it) however when i try to access the application through I'm getting this error. I'm using 2.0 framework

And here's my web.config

        <add name="ADConnectionString" connectionString="LDAP://,DC=com"/>

 <identity impersonate="true"/>
        <membership defaultProvider="MyADMembershipProvider">
                <add name="MyADMembershipProvider" 
                type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=,               Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 

The underlying connection was closed: An unexpected error occurred on a send.


I am consuming a third party web service wsdl using my .net aps.net page. And I am getting following error message. Cannt get to resolve it. Its working on my machine but not in my development machine. I have installed the certificate also in certificates on that machine. Can somone please help.?

Error -->  The underlying connection was closed: An unexpected error occurred on a send.





ASMX ws: An unexpected error occurred on a receive; failing intermittently



we I have asmx web service, this seems to be working fine for 25 client machines but one site keeps failing. The client gets a small dataset and tries to send it across to server to process. The dataset saved in XML file only makes 450 - 550kB. The web service is contacted twice in a short time every half an hour. The other smaller dataset (50kB) goes across everytime without any troubles. This site is not trying to send the biggest dataset, other site are sending much bigger datasets without problem. The catch is this failing site keeps retrying for 20 times (10 hours) in average and then eventually goes across. I don't think the service webmethod is erroring out as that is all wrapped up in the try and catch and the exception is not getting thrown, also every other try for the exact same webmethod used by any other client site seems to be working fine.

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Ne

"An error occurred while retrieving data from Oracle Instance..."


I have succeffuly Imported the ADF and have also successfully created a Business Data Column. But when I try to query data , I get the following error

An error occurred while retrieving data from Oracle Instance. Administrator, see the server log for more information

And this is what I found in the Application Logs
A Metadata Exception was constructed in App Domain '/LM/W3SVC/81256521/ROOT-1-129217212004078822'. The full exception text is: LobSystem could not be found using criteria 'id=476'.

'An unexpected error has occurred' on upload after changing limit



I recently changed the max upload size for attachments to TFS work items on our SharePoint site.  I did this by going to the http://tfsserver1:8080/tfs/ProductCollection/WorkItemTracking/v1.0/ConfigurationSettingsService.asmx?op=SetMaxAttachmentSize URL and entering the new size in bytes.

This worked a treat, but not I cannot upload any documents to another site on the same server.

I can open and save documents that are already there, but when I click the 'Upload' button it gives a white page with 'An unexpected error has occurred.' on it.

Is there something else I have to set when I increase the upload limit for work items?


Writing Bitmap to Response.OutputStream - Generic Error Occured in GDI+



This is what I'm trying to do when I get the error on the server (it works on my local machine):

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image); 

Response.ContentType = "image/bmp";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp);

I don't think it can be a permissions problem because this works on the server:

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image);

Response.ContentType = "image/jpeg";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

So how do I get this to work for a bitmap?


System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a rec

Hello Guys,         I am getting following exception while web service (ASMX) is returning the response. <!-- [if gte mso 10]> <mce:style> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.     <!-- [if gte mso 10]> <mce:style>                                                     InnterException (System.IO.Exception): "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."       I think either the Asp.net web server is closing the connection or the response is too long.   Following is my simple code.    1)   namespace JFA.IndiePay.BusinessAccess { public class VerTexProcessor { public DataSet ProcessVerTexForBatch(DataSet dsInputRequest) { DataSet dsResponse = new DataSet(); //Call vertex web service here. VertexService.Service texCalculator = new VertexService.Service(); texCalculator.Timeout = 500000;

A FileStore error from WriteFile occurred

Hi- I am working with Decision Tree mining model with the Model specs as below. The source for training data is a table from sql server 2008 with 210 Million rows. Structure is as below. Upon training the Model, at some point through the training process, It errors with the below message File system error: A FileStore error from WriteFile occurred. Physical file: \\?\M:\OLAP\Data\KWProject.0.db\MiningStructureHooks ~MC-Phrases Key.7.dim\11.Phrases Key.asstore. Logical file: . . Observing the file grow in the File location M:\OLAP\Data\KWProject.0.db\MiningStructureHooks ~MC-Phrases Key.7.dim\11.Phrases Key.asstore, it seems to error out when reaching around 4GB. I have seen other sites/forums with same errors and the resolution being either using ROLAP or ByAttribute/ByTable or setting the <PropertyBufferRecordLimitEnabled>1</PropertyBufferRecordLimitEnabled> to 1 in the msmdsrv.ini file. Since this is not a cube, ROLAP and ByAttribute setting didnt apply here. I have tried with the PropertyBufferRecordLimitEnabled setting to a 1 but with no luck. Model and source table structure is as below- Key  bigint (Key) Pages  int (Predict) Views  int (Predict) Count  int Frequency float MK  varchar(10) Priority int Restricted int Forum  int Rows in the table: 210 Million I have tr

An error occurred during client rendering

Hi Guys, Can anyone help me with the error message prompting after the deployment of simple report. It works fine in VS and report builder but some reason I am getting below error message when you define parameter after the deployment. I am mean to say on http://localhost/Reports/   An error occurred during client rendering. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Thanks in advance, D

Error: A native exception has occurred in my_file.exe

Hello everyone,   This error is occurring with me when I am working with SSCE in my pocket PC. Can anyone tell me why?   Thanks!

Server ERROR: An error occurred during the parsing of a resource required to service this request.

I have created one asp.net 2.0 application and created a setup project. I run this setup in my local machine, the application run fine, but i uploaded into online server I met the following parser error.How to solve this error? Kindly help me. Very urgent.. Kamal....

The underlying connection was closed: An unexpected error occurred on a receive

Hi All,   i have developed a web application to call WCF service (which is hosted in IIS) from client application using .Net 1.1 it works fine.   but i got an error "The underlying connection was closed: An unexpected error occurred on a receive." when the return object is getting complex.   i analysis the issue with different level of object complexity and i found it get failed for following structure.   eg:   ObjectA - outer object that has some primitive data types and the list of ObjectB ObjectB - this also contain some primitive data and list of ObjectC.   Hope you can understand the hierarchy (complexity) of the return object. This works up to 2nd level of object hierarchy.   Does anyone have idea about the solution for this exception?   Thanks in Advance Shazvi
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend