C# 使用 4G Dongle APN 连接到移动网络

问题描述

我正在开发一个自定义应用程序,使用户能够通过 USB 移动 4G 加密狗连接到互联网。

问题是我只能使用 DotRas.dll 库通过号码 *99# 连接到 3G 网络

代码片段,使用预定义的 Windows 连接拨号进行连接

private void ConnectRas(string entryName)
{
    try
    {
        var x = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
        var path = File.Exists(x) ? x : @"C:\ProgramData\Microsoft\Network\Connections\Pbk\rasphone.pbk";

        if (!File.Exists(path))
            return;

        RasConnection conn = RasConnection.GetActiveConnections().FirstOrDefault(o => o?.EntryName == entryName);
        var state = conn?.GetConnectionStatus().ConnectionState;

        if (state == RasConnectionState.Connected)
            return;

        using (var dialer = new RasDialer())
        {
            dialer.EntryName = entryName;
            dialer.PhoneBookPath = path;
            //dialer.Credentials = new NetworkCredential("User","Password");
            dialer.Dial();
        }
    }
    catch (Exception e)
    {
        this.GetLogger().Error(e,e.Message);
    }
}

我需要能够直接从 C# 输入 APN 主机名、用户名密码并连接到 4G 网络而不是 3G。

请帮忙。谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)