In my previous post of Bitmap.save(): A generic error occurred in GDI+. I explained about the lock which the Bitmap object creates on the file. Now if by mistake we dispose the object before saving the image, there is no image to be saved and the error “Invalid Parameter Used” will be encountered. You can generate this error by following code.
Dim oBitmap As Bitmap
oBitmap = New Bitmap("c:\\example.jpg")
Dim oGraphic As Graphics
oGraphic = Graphics.FromImage(oBitmap)
Dim oBrush As New SolidBrush(Color.Black)
Dim ofont As New Font("Arial", 8 )
oGraphic.DrawString("Some text to write", ofont, oBrush, 10, 10)
' Here bitmap object is disposed before saving it.
oBitmap.Dispose()
oBitmap.Save("c:\\example.jpg",ImageFormat.Jpeg)
oGraphic.Dispose()
Try the following code
Dim oBitmap As Bitmap
oBitmap = New Bitmap("c:\\example.jpg")
Dim oGraphic As Graphics
oGraphic = Graphics.FromImage(oBitmap)
Dim oBrush As New SolidBrush(Color.Black)
Dim ofont As New Font("Arial", 8 )
oGraphic.DrawString("Some text to write", ofont, oBrush, 10, 10)
oBitmap.Save("c:\\example.jpg",ImageFormat.Jpeg)
oBitmap.Dispose()
oGraphic.Dispose()
You will get the above mentioned error:A generic error occurred in GDI+. This problem occurs because until the bitmap object is disposed, it creates a lock on the underlying image file. So you can save the newly generated file with different name but not overwrite the file because of lock. Now suppose you want to overwrite the file then create another bitmap from old bitmap. dispose the object of old bitmap, process new bitmap object and save the new bitmap object with original file name. The above chunk of code should be written in the following way.
Dim oBitmap As Bitmap
oBitmap = New Bitmap("c:\\example.jpg")
Dim oGraphic As Graphics
' Here create a new bitmap object of the same height and width of the image.
Dim bmpNew As Bitmap = New Bitmap(oBitmap.Width, oBitmap.Height)
oGraphic = Graphics.FromImage(bmpNew)
oGraphic.DrawImage(oBitmap, New Rectangle(0, 0, _
bmpNew.Width, bmpNew.Height), 0, 0, oBitmap.Width, _
oBitmap.Height, GraphicsUnit.Pixel)
' Release the lock on the image file. Of course,
' image from the image file is existing in Graphics object
oBitmap.Dispose()
oBitmap = bmpNew
Dim oBrush As New SolidBrush(Color.Black)
Dim ofont As New Font("Arial", 8 )
oGraphic.DrawString("Some text to write", ofont, oBrush, 10, 10)
oGraphic.Dispose()
ofont.Dispose()
oBrush.Dispose()
oBitmap.Save("c:\\example.jpg", ImageFormat.Jpeg)
oBitmap.Dispose()
Check it out for event handler. It is quite possible that if you cut and paste the datagrid from one place to another, it will loose all the event handlers which were previously defined.
If you think that event handler is defined correctly, check out how the datasource is bound to the datagrid. Your code should bind the datasource when there is no postback.
If not Page.IsPostback Then BindGrid()End If
Otherwise on each postback, the datagrid will be bound to the datasource resulting in ItemCommand Event not fired.
Description: An error occurred during the processing of a configuration file required to service this request.Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Access is denied: ‘Ajax’.
Source Error:
Line 196:
Line 197:
Line 198: Line 199: Line 200:
Source File: c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config Line: 198
Assembly Load Trace: The following information can be helpful to determine why the assembly ‘Ajax’ could not be loaded.
There are three solutions for this error. Try it one by one.
- Give the user “machine_name\ASPNET” appropriate access rights on Ajax.dll (Right click on the file. Go to “Properties…” > “Security” and then select the user and check appropriate box for permission.)
- Indexing service do not refresh the list of dlls. So If you are running Indexing service, it locks dll and this error message pops up, so disable Indexing service. Read more about disabling Indexing service at Access Denied Error
- If Indexing service is already disabled, then the culprit is your antivirus program. Disable all antivirus programs, antispy or antixyz programs you have. Now again try to get the same error. I bet you wont get it.
Cheers……
I recently installed Microsoft Visual Studio Express Edition. It
also installed .NET framework 2.0 in my machine. When I wanted to
switch to the different version, I used “ASP .NET” tab in the IIS MMC
> Default Website > Properties. After few days suddenly the tab
“ASP .NET” disappeared. Now there was no way I can change the version.
When I tried to create new web application project, it halted with some
error.(Cann’t remember now!!!) Then I found ASP .NET application
switcher developed by Denis Bauer. It is a nice tool to change the version. Now it became one of my “Must Have” repository tools.