修复Microsoft.VisualBasic.CompilerServices.ProjectData.ClearProjectError vbc编译错误

时间:2018-03-09 15:25:28

标签: vb.net

我有一个简单的vb.net项目,它基本上是一个名为FiveM的GTAV修改框架的脚本。这不是很重要,所以,FiveM有一个c#运行时,使用Mono。由于我比c#tho更了解vb.net,所以我决定尝试使用vb.net作为脚本,知道它们都编译成MSIL。显然,由于运行时是针对c#的,因此它不包含vb运行时dll(Microsoft.VisualBasic),因此我必须使用/ vbruntime-flag和/ nostdlib / define编译我的脚本:_MYTYPE = \“Empty \ ”。 对于简单的脚本,它工作正常,但现在我面临更大的挑战。所以,这是我的代码:

Imports CitizenFX.Core.Native.API
Imports CitizenFX.Core
Imports System.Threading
Imports System.Threading.Tasks
Imports System

Namespace WarThunderVClient

Public Class WarThunderVClient
    Inherits BaseScript
    Private flightstate = 1
    Public Sub New()
       OnTick()
    End Sub
    Public Sub DrawPlaneHUD()
        Dim speed As Double = GetEntitySpeed(GetVehiclePedIsIn(PlayerPedId(), False)) * 1.943844492
        Dim altitude As Double = GetEntityCoords(PlayerPedId(), True).Z * 3.28084
        Dim heading As Double = GetEntityHeading(GetVehiclePedIsIn(PlayerPedId(), False))
        Dim verticalspeed As Double = GetEntityVelocity(GetVehiclePedIsIn(PlayerPedId(), False)).Z * 196.850394
        If speed < 40 Then speed = 0
        If speed > 200 Then speed = 200
        If verticalspeed > 2000 Or verticalspeed < -2000 Then verticalspeed = 2000
        If altitude < 0 Then altitude = 0
        If Not HasStreamedTextureDictLoaded("flightinstruments") Then
            RequestStreamedTextureDict("flightinstruments", True)
            While Not HasStreamedTextureDictLoaded("flightinstruments")
                Wait(1)
            End While
        End If
        DrawSprite("flightinstruments", "speedometer", 0.9, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "speedometer_needle", 0.9, 0.9, 0.08, 0.08 * 1.77777778, ((speed - 20) / 20) * 36, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "altimeter", 0.8, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "altimeter-needle100", 0.8, 0.9, 0.08, 0.08 * 1.77777778, altitude / 100 * 36, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "altimeter-needle1000", 0.8, 0.9, 0.08, 0.08 * 1.77777778, altitude / 1000 * 36, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "altimeter-needle10000", 0.8, 0.9, 0.08, 0.08 * 1.77777778, altitude / 10000 * 36, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "heading", 0.7, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "heading_needle", 0.7, 0.9, 0.08, 0.08 * 1.77777778, heading, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "verticalspeedometer", 0.6, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
        DrawSprite("flightinstruments", "verticalspeedometer_needle", 0.6, 0.9, 0.08, 0.08 * 1.77777778, 270 + (verticalspeed / 1000 * 90), 255, 255, 255, 255)
    End Sub
    Public Sub DrawHelp(text As String, isloop As Integer, isbeep As Integer, isshape As Integer)
        If Not IsHelpMessageOnScreen() Then
            SetTextComponentFormat("STRING")
            AddTextComponentString(text)
            DisplayHelpTextFromStringLabel(0, isloop, isbeep, isshape)
        End If
    End Sub
    Public Async Sub OnTick()
        While True
            If IsPedInAnyPlane(PlayerPedId()) Then
                If flightstate.Equals(1) Then
                    SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), False, False, False)
                End If
                If Not GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId(), False)) Then
                    DrawHelp("Press ~INPUT_DETONATE~ to perform an engine startup", 0, 1, -1)
                    If IsControlJustPressed(3, 47) Then
                        flightstate = 2
                        SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), True, False, False)
                    End If
                End If
                DrawPlaneHUD()
            End If
            Await Delay(0)
        End While
    End Sub
End Class
 End Namespace

因此,使用此命令使用vbc进行编译时:

vbc /libpath:"C:\Users\admin\source\repos\basic-resource\BasicResourceClient\bin\Release" /reference:CitizenFX.Core.dll /novbruntimeref /target:library WarThunderVClient.vb /vbruntime- /noconfig /nostdlib /define:_MYTYPE=\"Empty\" /out:WarThunderVClient.net.dll /r:system.dll  

最初输出关于“=”运算符的错误:

  

错误BC35000:请求的操作不可用,因为   'Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual'   没有定义运行时库的功能。

使用.Equals()方法轻松修复了这个问题, 但现在又输出了另外两个错误,我对如何修复没有任何想法:

  

错误BC35000:请求的操作不可用,因为   运行时库   'Microsoft.VisualBasic.CompilerServices.ProjectData.ClearProjectError'   函数未定义。

        Public Async Sub OnTick()
            While True
                If IsPedInAnyPlane(PlayerPedId()) Then
                    If flightstate.Equals(1) Then
                        SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), False, False, False)
                        End If
                    If Not GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId(), False)) Then
                            DrawHelp("Press ~INPUT_DETONATE~ to perform an engine startup", 0, 1, -1)
                            If IsControlJustPressed(3, 47) Then
                            flightstate = 2
                            SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), True, False, False)
                            End If
                    End If
                    DrawPlaneHUD()
                End If
                Await Delay(0)
            End While
        End Sub
  

C:\ Users \用户管理\下载\服务器\资源\ GG \ WarThunderVClient.vb(50)   :错误BC35000:请求的操作不可用,因为   运行时库   'Microsoft.VisualBasic.CompilerServices.ProjectData.SetProjectError'   函数未定义。

        Public Async Sub OnTick()
            While True
                If IsPedInAnyPlane(PlayerPedId()) Then
                    If flightstate.Equals(1) Then
                        SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), False, False, False)
                        End If
                    If Not GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId(), False)) Then
                            DrawHelp("Press ~INPUT_DETONATE~ to perform an engine startup", 0, 1, -1)
                            If IsControlJustPressed(3, 47) Then
                            flightstate = 2
                            SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), True, False, False)
                            End If
                    End If
                    DrawPlaneHUD()
                End If
                Await Delay(0)
            End While
        End Sub

这是否有解决方法?

1 个答案:

答案 0 :(得分:0)

ProjectData.ClearProjectError用于所谓的VB应用程序框架。该框架的很大一部分是支持向VB6语言功能的向后兼容性,如On Error Resume Next,没有合格的VB.Net程序员可以使用。

转到项目菜单 - &gt; ProjName属性 - &gt;应用程序选项卡,并清除&#34;启用应用程序框架&#34;的复选标记。更改&#34;启动对象&#34;下拉到&#34; Sub Main&#34;。

然后,您需要将Sub Main定义为您的程序的入口点。

Module Module1
    <STAThread>
    Sub Main(args As String())
        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)
        Application.Run(New Form1())
    End Sub
End Module