+ Start a Discussion
juventussjuventuss 

Unhandled Exception: System.IO.IOException: Unable to create a transport connection.

I am quite puzzled by this error. To give you a background, we're in the process of migrating from Saleslogix to salesforce. We have an internal quoting software written in VB6. The software has been migrated to vb.net and runs without issues.

Here is where it gets wierd. I am able to create a form from scratch and perform a test login into salesforce.com. here is the code below.

[quote]Imports salesforce_connector.sforce
Public Class frmlogin
Inherits System.Windows.Forms.Form
Private binding As sforce.SforceService
Private loggedIn As Boolean = False
Private loginRes As LoginResult = Nothing
Private accounts() As String = Nothing
Private contacts() As String = Nothing
Private tasks() As String = Nothing
Private serverTime As DateTime

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents cmdlogin As System.Windows.Forms.Button
Friend WithEvents lblurl As System.Windows.Forms.Label
Friend WithEvents lblsession As System.Windows.Forms.Label
Friend WithEvents txtuname As System.Windows.Forms.TextBox
Friend WithEvents txtpword As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Public WithEvents Image1 As System.Windows.Forms.PictureBox
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents cmdexit As System.Windows.Forms.Button
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmlogin))
Me.txtuname = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.txtpword = New System.Windows.Forms.TextBox
Me.cmdlogin = New System.Windows.Forms.Button
Me.lblurl = New System.Windows.Forms.Label
Me.lblsession = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Image1 = New System.Windows.Forms.PictureBox
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.cmdexit = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'txtuname
'
Me.txtuname.Location = New System.Drawing.Point(120, 24)
Me.txtuname.Name = "txtuname"
Me.txtuname.Size = New System.Drawing.Size(200, 20)
Me.txtuname.TabIndex = 0
Me.txtuname.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 1
Me.Label1.Text = "&Username"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(104, 23)
Me.Label2.TabIndex = 3
Me.Label2.Text = "&Password"
'
'txtpword
'
Me.txtpword.Location = New System.Drawing.Point(120, 56)
Me.txtpword.Name = "txtpword"
Me.txtpword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtpword.Size = New System.Drawing.Size(200, 20)
Me.txtpword.TabIndex = 2
Me.txtpword.Text = ""
'
'cmdlogin
'
Me.cmdlogin.Location = New System.Drawing.Point(8, 8)
Me.cmdlogin.Name = "cmdlogin"
Me.cmdlogin.Size = New System.Drawing.Size(88, 32)
Me.cmdlogin.TabIndex = 4
Me.cmdlogin.Text = "&Login"
'
'lblurl
'
Me.lblurl.Location = New System.Drawing.Point(48, 208)
Me.lblurl.Name = "lblurl"
Me.lblurl.Size = New System.Drawing.Size(568, 23)
Me.lblurl.TabIndex = 5
'
'lblsession
'
Me.lblsession.Location = New System.Drawing.Point(48, 248)
Me.lblsession.Name = "lblsession"
Me.lblsession.Size = New System.Drawing.Size(568, 23)
Me.lblsession.TabIndex = 6
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(120, 224)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(288, 23)
Me.Label3.TabIndex = 7
Me.Label3.Text = "Label3"
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(440, 0)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(152, 80)
Me.PictureBox1.TabIndex = 12
Me.PictureBox1.TabStop = False
'
'Image1
'
Me.Image1.Cursor = System.Windows.Forms.Cursors.Default
Me.Image1.Image = CType(resources.GetObject("Image1.Image"), System.Drawing.Image)
Me.Image1.Location = New System.Drawing.Point(368, 0)
Me.Image1.Name = "Image1"
Me.Image1.Size = New System.Drawing.Size(72, 80)
Me.Image1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.Image1.TabIndex = 11
Me.Image1.TabStop = False
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.txtuname)
Me.GroupBox1.Controls.Add(Me.txtpword)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Location = New System.Drawing.Point(16, 80)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(336, 104)
Me.GroupBox1.TabIndex = 13
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Salesforce Login"
'
'cmdexit
'
Me.cmdexit.Location = New System.Drawing.Point(96, 8)
Me.cmdexit.Name = "cmdexit"
Me.cmdexit.Size = New System.Drawing.Size(96, 32)
Me.cmdexit.TabIndex = 14
Me.cmdexit.Text = "E&xit"
'
'frmlogin
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(632, 465)
Me.Controls.Add(Me.cmdexit)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Image1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.lblsession)
Me.Controls.Add(Me.lblurl)
Me.Controls.Add(Me.cmdlogin)
Me.Name = "frmlogin"
Me.Text = "Acs Fastquote/Salesforce login"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub cmdlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdlogin.Click
'test login functionality
Dim uname As String
Dim pword As String
uname = txtuname.Text
pword = txtpword.Text
' frmlogin.ActiveForm.Text = ""
' frmlogin.ActiveForm.Text = ("Creating the binding to the web service...")
'* Create the binding to the sforce servics
'*/
binding = New SforceService

'// Time out after a minute
binding.Timeout = 60000

'//Attempt the login giving the user feedback
' frmlogin.ActiveForm.Text = ("LOGGING IN NOW....")
Try
loginRes = binding.login(uname, pword)
Catch err As System.Web.Services.Protocols.SoapException
'// This is likley to be caused by bad username or password
MsgBox(err.Message & ", please try again." & vbCrLf & vbCrLf & "Hit return to continue...")
txtuname.Clear()
txtpword.Clear()
txtuname.Focus()

Return
Catch ex As Exception
'// This is something else, probably comminication
MsgBox(ex.Message & ", please try again." & vbCrLf & vbCrLf & "Hit return to continue...")
txtuname.Clear()
txtpword.Clear()
txtuname.Focus()

Return
End Try

lblurl.Text = ("The New Server Url is:" & loginRes.serverUrl)
lblsession.Text = ("The Session ID is:" & loginRes.sessionId)

'//Change the binding to the new endpoint
binding.Url = loginRes.serverUrl

'//Create a new session header object and set the session id to that returned by the login
binding.SessionHeaderValue = New sforce.SessionHeader
binding.SessionHeaderValue.sessionId = loginRes.sessionId
Debug.WriteLine(loginRes.sessionId)
loggedIn = True

If lblurl.Text Label3.BackColor = System.Drawing.Color.Green
'frmlogin.ActiveForm.Text = "Login Successful..."
End If

'// call the getServerTimestamp method
'getServerTimestamp()

'//call the getUserInfo method
'getUserInfo()

'Return True
If loginRes.sessionId 'Me.Hide()

' System.Diagnostics.Process.Start("C:\Program Files\Fastquote.net\FastQuote.exe")
End If

End Sub

Private Sub cmdexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.Click
Me.Text = "CANCEL"
Me.Hide()
'frmBuildQuote.DefInstance.Show()
End
End Sub
End Class[/quote]

Now the above is a stand alone and it works fine. Now when i create a new form in our quoting application, with the exact same code, it gets stuck when attempting to authenticate login.
Here is an output of the error

[quote]'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'FastQuote': Loaded 'C:\acs\vb\Quotes\FastQuote.NET\bin\FastQuote.exe', Symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\microsoft.visualbasic.compatibility\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualbasic.compatibility.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\acs\vb\quotes\fastquote.net\bin\axinterop.klogctlproject.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\acs\vb\quotes\fastquote.net\bin\axinterop.mscomdlg.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\acs\vb\quotes\fastquote.net\bin\interop.klogctlproject.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\accessibility\1.0.5000.0__b03f5f7f11d50a3a\accessibility.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\acs\vb\quotes\fastquote.net\bin\interop.mscomdlg.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\dao\10.0.4504.0__31bf3856ad364e35\dao.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\microsoft.office.interop.excel\11.0.0.0__71e9bce111e9429c\microsoft.office.interop.excel.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded.
'FastQuote.exe': Loaded 'c:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded.
'FastQuote.exe': Loaded 'oyy3g7uy', No symbols loaded.
An unhandled exception of type 'System.IO.IOException' occurred in system.dll

Additional information: Unable to create a transport connection.


Unhandled Exception: System.IO.IOException: Unable to create a transport connection. ---> System.Net.Sockets.SocketException: The requested service provider could not be loaded or initialized
at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
at System.Net.Connection.StartConnectionCallback(Object state, Boolean wasSignalled)
--- End of inner exception stack trace ---
at System.Net.Connection.StartConnectionCallback(Object state, Boolean wasSignalled)An unhandled exception of type 'System.IO.IOException' occurred in system.dll

Additional information: Unable to create a transport connection.


Unhandled Exception: System.IO.IOException: Unable to create a transport connection. ---> System.Net.Sockets.SocketException: The requested service provider could not be loaded or initialized
at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
at System.Net.Connection.StartConnectionCallback(Object state, Boolean wasSignalled)
--- End of inner exception stack trace ---
at System.Net.Connection.StartConnectionCallback(Object state, Boolean wasSignalled)[/quote]

Is there something i am doing wrong ?

Message Edited by juventuss on 02-22-2005 03:47 PM

DevAngelDevAngel

Hi juventuss,

When you run this form as a windows forms application it runs fine, but when you try to launch the form from your quoting application, you get a socket error, correct?

Not sure what the issue might be, but I'd start by verifying that all required references are in place. 

Also, how are you creating the form in your quoting app?

juventussjuventuss
Yes thats what happens.

If i create a new project in vb.net the build runs perfectly and i am able to login to salesforce.com

Now when i open my project in vb.net and add a new form to the project with the same EXACT code as above, it errors out with the debug output shown above.

All references are in place. Could there be some sort of conflict i am not catching ? Your assistance would be greatly appreciated.

Thanks
SuperfellSuperfell
I'd guess your quoting application is changing some kind of global config which is then tripping up the Web services client, perhaps its registering a global proxy server setting, or changing the WebRequest protocol -> handler class mappings.
juventussjuventuss
THe quoting app has no interaction with the web. I have even made the saleforce login form the start up object but still get the same error.
juventussjuventuss
any suggestions ? Our implementation is pretty much stuck unless this problem is resolved.
SuperfellSuperfell
If it works fine outside of the quoting app, then something in the quoting app (either programiatically, or via an app.exe.config file) is changing the something in the environment which affects the .NET web services client.
If you can't see anywhere that changes the default proxy, WebRequest protocol mappings, or messes with global socket configuration, then i think you'll need to take it to Microsoft PSS.
iva030iva030
Juventuss,

Did you ever find a resolution to this problem? I am having the same issue with an app.
When our c#/.NET pgm executes standalone (called from command line or debugger) it is able to make a connection to the server we are trying to access. However, when I call the same program from our Java application, I get the following:

>>Unhandled Exception: System.IO.IOException: Unable to create a transport connection. ---> System.Net.Sockets.SocketException: The requested service provider could not be loaded or initialized
>> at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
>> at System.Net.Connection.StartConnectionCallback(Object state, Boolean wasSignalled)
>> --- End of inner exception stack trace ---
>> at System.Net.Connection.StartConnectionCallback(Object state, Boolean wasSignalled)


We are in desperate need of a solution to this issue.

Thanks,
Ivan