Ank*_*esh 1 c# vb.net vb.net-to-c#
我试图将VB.NET项目转换为C#.我按要求传递所有表单和类,但我不知道从ApplicationEvents.vb中编写事件需要从哪里开始(我相信它的属性是autoGenerated)
这是我的ApplicationEvent.vb文件中的代码:
Imports GM.Powertrain.RemoteCopy.Interfaces
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Remoting.Channels
Namespace My
Partial Friend Class MyApplication
Private Shared serviceConfig As ServiceConfig =
serviceConfig.Load()
Protected Overrides Function OnStartup(
ByVal eventArgs As StartupEventArgs) As Boolean
Dim channel As TcpChannel = New TcpChannel()
ChannelServices.RegisterChannel(channel, False)
Me.MainForm = New Computer_Network_MAIN_SCREEN()
Return MyBase.OnStartup(eventArgs)
End Function
Public ReadOnly Property Config() As ServiceConfig
Get
Return serviceConfig
End Get
End Property
Public ReadOnly Property LocalMachine() As IRemoteCopier
Get
Return serviceConfig.GetObject(Of IRemoteCopier)("localhost")
End Get
End Property
End Class
End Namespace
Run Code Online (Sandbox Code Playgroud)
此外,任何可能有助于此转换的提示将不胜感激.谢谢!
小智 5
在c#中没有ApplicationEvent.vb的等效文件.但是,在Program.cs中启动循环之前,您可以编写OnStartup函数中的任何代码.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//code in OnStartUp
Application.Run(new Form1());
Application.ApplicationExit += Application_ApplicationExit;
}
static void Application_ApplicationExit(object sender, EventArgs e)
{
throw new NotImplementedException();
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
2786 次 |
| 最近记录: |