Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如果.exe文件中不包含interop.scripting,我该怎么办?_Vb.net - Fatal编程技术网

Vb.net 如果.exe文件中不包含interop.scripting,我该怎么办?

Vb.net 如果.exe文件中不包含interop.scripting,我该怎么办?,vb.net,Vb.net,看起来我正在使用互操作脚本 从错误来看,LogEvents函数似乎是使用需要互操作脚本的函数 logevents函数如下所示 See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.IO.FileNotFoundException

看起来我正在使用互操作脚本

从错误来看,LogEvents函数似乎是使用需要互操作脚本的函数

logevents函数如下所示

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'Interop.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Interop.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
   at Project1.listmanipulatorlight.LogEvents(String whatToLog, Boolean canRandom)
   at Project1.largelistmanipulator.unionManyFilesIntoResultTxt()
   at Project1.listManipulatorForm.cmdUnionAllTextFiles_Click(Object eventSender, EventArgs eventArgs)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
公共子日志事件(ByVal whatToLog作为字符串,可选ByVal canRandom作为布尔值=True)
静态logNumber为整数
将时间戳设置为字符串
timeStamp=CStr(Microsoft.VisualBasic.Now)
whatToLog=时间戳&&&whatToLog&Microsoft.VisualBasic.vbNewLine
尝试
调试.打印(whatToLog)
appendToTextFile(whatToLog,“log.txt”,Scripting.IOMode.ForAppending)
特例
结束尝试
如果txtLog什么都不是,那么
其他的
Text=txtLog.Text&whatToLog
Text=Microsoft.VisualBasic.Right(txtLog.Text,2000)
如果结束
System.Diagnostics.Debug.Print(“日志:”&whatToLog)
logNumber=logNumber+1
SuperGlobal.lockMeFirst(
分()
如果(Microsoft.VisualBasic.Rnd()<1.0#/10000或logNumber>100000.0)和canRandom,则
尝试
Dim col=fileToCol(“log.txt”)
如果列数>50000,则
列移除范围(0,列计数-10000)
如果结束
coltofile(col,“log.txt”,True)
特例
结束尝试
对数=0
'reserveMaintenance(“log.txt”)
如果结束
端接头
)
端接头

我看不到有什么特别有用的东西。我不知道interopt在用什么。interopt到底是什么?如何将Interop嵌入到.exe文件中,这样就不会出现此问题。

您可以轻松地将Interop.Scripting替换为.NET副本:appendToTextFile()使用它。不是很明显,是实时编译器生成了这个异常。改为使用StreamWriter或File.AppendAllText()。或者也复制interop DLL,这可能是您忘记执行的操作。如果使用我的函数appendtotextfile(),则错误将出现在方法project1.appendtotextfile中。如果您有此“Scripting.IOMode.ForAppending”,则此剪切命名空间可能是interop的一部分。您应该尝试使用.NET功能,从项目中删除Microsoft.VisualBasic
  Public Sub LogEvents(ByVal whatToLog As String, Optional ByVal canRandom As Boolean = True)
        Static logNumber As Integer

        Dim timeStamp As String

        timeStamp = CStr(Microsoft.VisualBasic.Now)

        whatToLog = timeStamp & " " & " " & whatToLog & Microsoft.VisualBasic.vbNewLine

        Try
            Debug.Print(whatToLog)
            appendToTextFile(whatToLog, "log.txt", Scripting.IOMode.ForAppending)
        Catch ex As Exception

        End Try


        If txtLog Is Nothing Then
        Else
            txtLog.Text = txtLog.Text & whatToLog
            txtLog.Text = Microsoft.VisualBasic.Right(txtLog.Text, 2000)
        End If
        System.Diagnostics.Debug.Print("Log:" & whatToLog)

        logNumber = logNumber + 1
        SuperGlobal.lockMeFirst(
            Sub()
                If (Microsoft.VisualBasic.Rnd() < 1.0# / 10000 Or logNumber > 100000.0) And canRandom Then
                    Try
                        Dim col = fileToCol("log.txt")
                        If col.Count > 50000 Then
                            col.RemoveRange(0, col.Count - 10000)
                        End If
                        coltofile(col, "log.txt", True)
                    Catch ex As Exception
                    End Try
                    logNumber = 0
                    'reserveMaintenance("log.txt")
                End If
            End Sub
        )
    End Sub