Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi my name is vishal for 3 days i have been breaking my head on how to fix error COM Exception was unhandled: Exception from HRESULT:0x800A9C46 in c# windows forms.

I have a winsock control named:sckClient in my c# windows forms.

I got winsock control in my toolbox through toolbox-> right click->choose items->COM Components-> Microsoft WinSock control,version 6.0.

I have included namespaces: using System.Net;
using System.Net.Sockets; in my c# windows forms

Any way after connecting to server i wanted to send data to server through a timer control.
Given below is c# code:
C#
private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            sckClient.SendData("\u00fa" + "\u0000" + "\u0069" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u00fb");           
    }

But upon executing the above code i get error message(run-time error): COM Exception was unhandled:
Exception from HRESULT:0x800A9C46
in this below line :
C#
sckClient.SendData("\u00fa" + "\u0000" + "\u0069" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u00fb");


However i was able to accomplish my task which was in vb6 code. Given below is vb6 code:
VB
Private Sub Timer1_Timer(index As Integer)
    On Error GoTo errh
    Timer1(index).Enabled = False
    
    If (Timer1(index).Tag = "") Then   'Sync API call
        sckClient(index).SendData Chr(250) & Chr(0) & Chr(105) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(251)
    Else    'Get Last test data API call
        sckClient(index).SendData Chr(250) & Chr(0) & Chr(104) & Chr("0") & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(251)
    End If
    Timer1(index).Tag = ""
    Exit Sub
errh:
    MsgBox "syncing error:" & Err.Description, vbCritical
End Sub

Upon executing the above vb6 code i get to transmit data to server where i transmit data 2500105000000251 indicating server and client has been connected upon connection.

Can anyone help on how to achieve the same result with timer in c# windows forms with sql server 2008 as i was able to achieve in vb6 with Ms access.

Can anyone help me please?! Can anyone help me/guide me on how to solve my problem.? Any guidance/help in solving of this problem would be greatly appreciated!
Posted
Comments
Bernhard Hiller 25-Jun-14 6:15am    
What's the signature of "SendData"?
I suspect a problem with 8bit character set vs. unicode.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900