سؤال

I am using DotRas 1.3.4823.23273 for Windows 7 with a Hauwei E3131 HSPA+ USB modem. I have the following function which is intended to dial the reas connection for the modem.

    public void Connect(string dialerEntryName) 
    {
        string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
        using (RasDialer dialer = new RasDialer())
        {
            dialer.EntryName = dialerEntryName;
            dialer.PhoneBookPath = path;
            try
            {
                dialer.Dial();
            }
            catch (Exception ex) { }
        }
    }

I get an error 628 when trying to dial the connection.

The connection was terminated by the remote computer before it could be completed.

However when I dial the connection manually from my dialup connections in Windows 7 it works. The error only happens when I try to dial with DotRas.

I had this working not long ago. I am not sure what changed or what went wrong. I know I can probably dial the modem via AT commands but I would much prefer using the Windows dial up connections for this purpose.

هل كانت مفيدة؟

المحلول

It turns out that when saving credentials in the RAS connection there is a setting that must be enabled on the DotRas dialer, otherwise it seems to attempt to dial without any credentials.

    public bool Connect(string dialerEntryName)
    {
        string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
        using (RasDialer dialer = new RasDialer())
        {
            dialer.EntryName = dialerEntryName;
            dialer.PhoneBookPath = path;
            dialer.AllowUseStoredCredentials = true;
            dialer.Dial();
            return true;
        }

    }

The connection works with the setting:

dialer.AllowUseStoredCredentials = true;

Added. I assume that manually specifying credentials will also work, but I have not confirmed this.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top