Try our conversational search powered by Generative AI!

Exception when importing Page Types - Safe handle has been closed

Vote:
 

Hello.

I'm working on a EPiServer 5 site and we have a problem when trying to import page types to some of our servers. When developing we're using Windows Server 2008 and the same OS on our test servers.

The problem is when we want to export our page types from our development environment into our test environment using the "Export data" / "Import data" functions in the Admin GUI. There's no problem validating the file but when we hit the "Import" button we get the following exception:

Exception: Safe handle has been closed[]

It doesn't matter if we try to use files exported from our development environment or if we just try to export one page type from test and then import it back again. Still the same error. The EPiServer log files doesn't give us anything nor does the Windows Event Log either.

Any ideas?

//J

#35147
Nov 30, 2009 10:52
Vote:
 

I ran into this bug while exporting pages and tracked down the issue to an exception that is thrown when trying to get the owner name of any files that are linked to a page. It only occurs when Windows authentication is turned on, so if it is an option to temporarily turn it off that works.

I reported the issue and and it's now being tracked as bug #26760. It is set to fixed but without details about version.

Here is my original bug report:

Our client reported an error during export of pages.
The following error message was displayed for each page that linked to a file:
"[Exporting page [ID]] Failed to export property [PropertyName], exception: Safe handle has been closed"

We were able to replicate and debug the error on a clean Windows Server 2008 with IIS7 in integrated mode with only the public templates installed. The error only occurs with Windows Authentication.

When trying to export a page with a file, an exception of type ObjectDisposedException (“Safe handle has been closed”) is thrown from the System.Security.Principal.WindowsIdentity.User property when trying to get the name of the current principal.
This is called from the VirtualPathProvider that is trying to log the request for that file.

Investigating the export package reveals that it is incomplete and that the page and file is not included.

Steps to reproduce
1. Setup a clean Windows Server 2008 with IIS7 Integrated mode.
2. Install EPiServer with Public templates
3. Turn on Windows Authentication
4. Add a file to the contents of a page
5. Go to Admin, Export and export that page
6. Error occurs
7. Export package is incomplete

 

I hope at least I could shed some light on your problem.

Cheers
Henrik

#35207
Nov 30, 2009 22:37
Vote:
 

Just wanted to say, I ran into this as well and I am also using windows auth. Thanks for providing the insight Henrik! I hope this will be fixed soon.

#36123
Jan 14, 2010 19:35
Vote:
 

For the record, this also occurs in scheduled jobs when deleting pages -- I assume the system checks the links of a page when deleting which triggers the same section of code.

#51297
Jun 01, 2011 4:32
Vote:
 

What's odd is that it's random.  I can run my job and get the error, then immediately re-run it (having made NO changes to it) and it will run without a problem.

#51299
Jun 01, 2011 5:07
Vote:
 
Run into this every time I try to change the Principal with windows authentication. In my case, I was able to change it using a generic principal.
PrincipalInfo.CurrentPrincipal = new GenericPrincipal(
                new GenericIdentity("Scheduled Task"),
                new[] { "Administrators" });
Magnus Rahl has blogged about it here: http://world.episerver.com/Blogs/Magnus-Rahl/Dates/2010/12/Run-a-scheduled-job-as-a-specific-role/
#64534
Edited, Dec 28, 2012 17:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.