任务计划程序不会运行我的.net控制台应用程序

时间:2018-11-12 08:17:22

标签: .net taskscheduler

我有一个将数据写入excel的应用程序。当我通过双击手动运行.exe时,它运行良好。 现在,我想按计划任务运行,但是在事件查看器中看到一个.net错误:

  

System.Runtime.InteropServices.COMException      在Microsoft.Office.Interop.Excel.Workbooks.Open(System.String,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System .Object,System.Object,System.Object,System.Object,System.Object,System.Object))

下面是部分代码:

    Dim testworkbook As Workbook = Nothing
    Dim testworksheet As Worksheet = Nothing
    Dim countcell As Integer = 1
    Dim failcell As Integer = 3
    Dim Machine As String
    Dim WMBBdate As String
    Dim OSCmachine As String
    Dim OSCdate As String

    Dim xls As New Microsoft.Office.Interop.Excel.Application
    xls.DisplayAlerts = False
    xls.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow


    testworkbook = xls.Workbooks.Open("\\YY088132\Users\310288557\Desktop\Virtual Line auto email\Test3.xlsx")
    testworksheet = testworkbook.Worksheets("Sheet1")
    testworksheet.UsedRange.Clear()
    testworksheet.Cells.Font.Color = ColorTranslator.ToOle(System.Drawing.Color.Black)

我怀疑它停在打开工作簿的行上。

我尝试了在Google上找到的所有可能的解决方案,例如:

    syswow64system32
  1. 创建 Desktop 文件夹
  2. DCOM配置
  3. 还有更多

0 个答案:

没有答案