开发者

Why does this File write fail after a SharePoint 2010 migration?

开发者 https://www.devze.com 2023-04-10 05:07 出处:网络
I migrated my MOSS 2007 application (with custom appr开发者_JS百科oval workflow) to Sharepoint 2010. I had this generic piece of code to log data

I migrated my MOSS 2007 application (with custom appr开发者_JS百科oval 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)

at System.Workflow.ComponentModel.ActivityExecutor1.Execute(Activity activity, ActivityExecutionContext executionContext)

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.


It can even occur if you are trying to refer to a removable medium too frequently. In my case, I was trying to display the remaining space in the disk by getting the information from the DriveInfo.GetDrives() method.

The code was called as soon as a few bytes were copied to the device. So, it's better to check if it's not the case. Do the exception handling and let it get the details when it is ready.


I don't know if this is related but I had a console app scheduled as a task and the task kept failing with "The device is not ready" when I went to manually run the console app from the command line I was shown an error that

"to run this application, you first must install one of the following versions of the .NET framework blah blah".

Why does this File write fail after a SharePoint 2010 migration?

0

精彩评论

暂无评论...
验证码 换一张
取 消