I migrated my MOSS 2007 application (with custom approval workflow) to Sharepoint 2010. I had this generic piece of code to log data
private void WriteToLog(String logInfo)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
File.AppendAllText(LOG_FILE_PATH + string.Format("{0:" + LOG_FILE_FORMAT + "}", DateTime.Now) + ".log", logInfo);
});
}
I have done a database detach upgrade, there are running workflows (In progress state) from the previous environment which should continue in sharepoint 2010. But unfortunately that does not happen , my replicator activity threw an error. I found this in the sharepoint log
System.IO.IOException: The device is not ready.
at System.IO._Error.WinIOError(Int32 errorCode, String maybeFullP ath)
at System.IO.FileStream.Init(String p ath, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY atTRIBUTES sec attrs, String msgP ath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String p ath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgP ath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String p ath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamWriter..ctor(String p ath, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String p ath, Boolean append, Encoding encoding)
at System.IO.File.AppendAllText(String p ath, String contents, Encoding encoding)
at xyz.Utils.MailNotific ations.DisplayClass1._0()
at Microsoft.SharePoint.SPSecurity.DisplayClass4._2()
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElev ated secureCode)
at Microsoft.SharePoint.SPSecurity.RunWithElev atedPrivileges(WaitCallback secureCode, Object param)
at Microsoft.SharePoint.SPSecurity.RunWithElev atedPrivileges(CodeToRunElev ated secureCode)
at xyz.Utils.MailNotific ations.WriteToLog(String logInfo)
at xyz.Utils.MailNotific ations.SPNotific ation(SPWeb applic ation, String subject, String approver, String htmlBody)
at xyz.WF.Approval.ApprovalWorkFlow.logError_ExecuteCode(Object sender, EventArgs e)
at System.Workflow.ComponentModel.Activity.RaiseEvent(DependencyProperty dependencyEvent, Object sender, EventArgs e)
at System.Workflow.Activities.CodeActivity.Execute(ActivityExecutionContext executionContext)
at System.Workflow.ComponentModel.ActivityExecutor1.Execute(T activity, ActivityExecutionContext executionContext)
1.Execute(Activity activity, ActivityExecutionContext executionContext)
at System.Workflow.ComponentModel.ActivityExecutor
at System.Workflow.ComponentModel.ActivityExecutorOper ation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
at System.Workflow.Runtime.Scheduler.Run()
In brief this seems to be an IO exception. I have shared the log folder location, file access permission is ruled out, the application works just fine when a new workflow is started.
What are LOG_FILE_PATH and LOG_FILE_FORMAT?
The IO exception could be caused if either are empty or invalid in some other way.