控制台应用程序在应用程序中抛出异常,但在调

时间:2015-12-30 10:24:14

标签: vb.net console-application

运行此简单代码时,每次在控制台应用程序中抛出异常

    Public Function convertWord(ByVal file As String, ByVal Path As String) As Integer

    Dim convertObj As Microsoft.Office.Interop.Word.Application
    Dim WordDoc As Microsoft.Office.Interop.Word.Document

    Try
        convertObj = New Microsoft.Office.Interop.Word.Application
        WordDoc = New Microsoft.Office.Interop.Word.Document
        WordDoc = convertObj.Documents.Open(Path)
        WordDoc.ExportAsFixedFormat(file, WdExportFormat.wdExportFormatPDF)
        Return 2
    Catch ex As Exception
        _checkLog("Originalna greška je : " & ex.Message & ex.StackTrace)
        Return 5
    End Try

End Function

如果我使用调试模式,这个功能很完美。否则

Log check: 30.12.2015. 11:17:15 Originalna greška je : Object reference not set to an instance of an object. Line 34

  

第34行>>> WordDoc = convertObj.Documents.Open(路径)

1 个答案:

答案 0 :(得分:1)

打开DCOM配置设置:

git checkout master
git reset --hard <commit SHA-1 of where you want master to be>
git push --force-with-lease <your remote> master

标签标识,从启动用户更改为交互式用户。