【发布时间】:2016-06-27 13:09:38
【问题描述】:
我无法将 vb.net 代码完全转换为 c# 代码,所以我决定制作一个 vb.net dll,然后将其添加到 c# 表单中。
但我对这个 dll 的东西很陌生,我不知道如何以 C# 形式访问对象。我将 C# 应用程序添加到 dll 中的引用,就像我为 dll 所做的那样。但我仍然无法访问 C# 应用程序中的计时器和 2 个标签。
这是我的 vb.net dll
Public Class Class1
Public Sub Bypass(block1 As String, block2 As String, ok1 As String, ok2 As String)
Try
Dim folderPath As String = Environment.GetFolderPath(SpecialFolder.Windows)
FileSystem.FileClose(New Integer() {1})
FileSystem.FileClose(New Integer() {2})
If My.Computer.FileSystem.FileExists((folderPath & "\xspirit.sys")) Then
FileSystem.FileOpen(1, (folderPath & "\xspirit.sys"), OpenMode.Append, OpenAccess.ReadWrite, OpenShare.LockReadWrite, -1)
Else
File.WriteAllBytes((folderPath & "\xspirit.sys"), New Byte() {0})
FileSystem.FileOpen(1, (folderPath & "\xspirit.sys"), OpenMode.Append, OpenAccess.ReadWrite, OpenShare.LockReadWrite, -1)
block1 = "Erişim Engellendi"
MsgBox("Erişim Engellendi xspirit")
End If
If My.Computer.FileSystem.FileExists((folderPath & "\xhunter1.sys")) Then
FileSystem.FileOpen(2, (folderPath & "\xhunter1.sys"), OpenMode.Append, OpenAccess.ReadWrite, OpenShare.LockReadWrite, -1)
Else
File.WriteAllBytes((folderPath & "\xhunter1.sys"), New Byte() {0})
FileSystem.FileOpen(2, (folderPath & "\xhunter1.sys"), OpenMode.Append, OpenAccess.ReadWrite, OpenShare.LockReadWrite, -1)
block2 = "Erişim Engellendi"
MsgBox("Erişim Engellendi xhunter1")
End If
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
Dim ex As Exception = exception1
ProjectData.SetProjectError(ex)
Dim exception As Exception = ex
ProjectData.ClearProjectError()
ProjectData.ClearProjectError()
End Try
Dim p As Process()
p = Process.GetProcessesByName("Wolfteam.bin") 'set wolfteam process
If p.Count = 1 Then ' if wolfteam process detected
ok1 = "XignCode Clear Başarılı"
ok2 = "XignCode Clear Başarılı"
MsgBox("XignCode Clear Başarılı xspirit")
MsgBox("XignCode Clear Başarılı xhunter1")
End If
End Sub
End Class
我尝试转换 C#,但我无法完全做到,所以我尝试使用此代码从我的 dll 访问对象,但我做不到(是的,我将其添加到引用中)。
C#app.Form1(直到这里还可以,但我无法继续此代码。它不接受其余部分)
其实我是想写这个的:
C#app.Form1.Timer1.Enabled = False or C#app.Form1.label1.Text = "test"
我也试过了:
Dim test1 As String="test"
'then acces them from C# and then:
vbnetdll.Class1 tt = new vbnetdll.Class1();
label1.Text=f.vbmethod.test1;
但我不能这样做。因为不接受。怎么了?
【问题讨论】:
-
很抱歉没有回答您的问题,只是想知道为什么您不能翻译所有内容?你试过翻译机吗?
-
绝对没有区别。 C# 和 VB.Net 都编译为 MSIL。您只需引用 dll 并开始使用它的对象,就像使用其他任何 C# dll 一样。
-
是的,但实际上它们效果不佳:/ 我试图自己翻译,但我无法到处翻译。我知道你可以添加 dll,但还是谢谢你。但我问了一些不同的问题。)