DotNetNuke Developer Chris Hammond

DotNetNuke Core Team Member

News

Cool Sites

My domains

Projects

DotNetNuke Daily Tip #5 6/28/06 Cannot access a closed file

Check out all of the DotNetNuke Daily Tips from Chris Hammond.

DotNetNuke Daily Tip for 6/28/2006

If you've ever received the following error while trying to upload a DotNetNuke module here's a quick fix.

ExceptionSystem.ObjectDisposedException: Cannot access a closed file. at System.IO.__Error.FileNotOpen() at System.IO.FileStream.Seek(Int64 offset, SeekOrigin origin) at System.Web.HttpRawUploadedContent.TempFile.GetBytes(Int32 offset, Int32 length, Byte[] buffer, Int32 bufferOffset) at System.Web.HttpRawUploadedContent.CopyBytes(Int32 offset, Byte[] buffer, Int32 bufferOffset, Int32 length) at System.Web.HttpInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at ICSharpCode.SharpZipLib.Zip.ZipInputStream.FillBuf(Int32 size) at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry() at DotNetNuke.Modules.Admin.ResourceInstaller.PaInstaller.ReadZipStream() at DotNetNuke.Modules.Admin.ResourceInstaller.PaInstaller.Install()

What version of DNN are you running? Is it 3.*? What version of the .Net framework is your site running on? If it's 2.0 that's most likely your case. We ran into this problem earlier today in our testing environment. To fix it, in IIS on the ASP.NET tab for your site be sure to set it to 1.1!

Thanks to Jianxiong for sending me the error message.

Stay tuned for another DotNetNuke Daily Tip coming tomorrow!

Comments

fariborz said:

hi dear thanks alot for your help I have that problem since past week and I can't solved it. thanks for your work. but why this problem occured?

# December 9, 2006 4:37 AM

Bob said:

DOES NOT WORK!

# October 24, 2007 10:23 AM

Chris Hammond said:

Great comment Bob, thanks for playing.

# October 24, 2007 10:38 AM

Ayman Wassif said:

I fixed my problem by suppressing the Finalize on the base stream after I opened the file

Here is the Line I added after opening the file

GC.SuppressFinalize(myLogStream.BaseStream);

Then at the class destructor I could Flush and Close the file

# November 12, 2007 11:18 AM

jag said:

Thank you Ayman.

This was driving me mad and your solution works.

# December 14, 2007 2:31 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)