.NET Framework Networking and Communication ForumDiscuss general managed code networking topics not relating to System.Net or Windows Communication Foundation (WCF).© 2009 Microsoft Corporation. All rights reserved.Tue, 24 Nov 2009 06:54:34 Z9a657749-56cc-4c35-af80-b514c8693c79http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ee6c8986-f321-4d19-b747-a4458a0f8708http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ee6c8986-f321-4d19-b747-a4458a0f8708sahil goyalhttp://social.msdn.microsoft.com/Profile/en-US/?user=sahil%20goyalretrive data from anu web site<strong>hiii awl<br/> <br/>            i m using c# with .net framework.i want to create an application which can fetch the updateable data from particular web site and send it to serial port at button click event. example:i want to fetch updateable scores from www.cricinfo.com threw my c# application. how is it possible plz give me some clue or some code for it.<br/> <br/>                                                                                                          thanks in advance.<br/>  </strong> <br/>Tue, 24 Nov 2009 05:54:05 Z2009-11-24T05:54:05Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/4d3d5b94-3dc4-4f25-8c7b-824236508fabhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/4d3d5b94-3dc4-4f25-8c7b-824236508fabPalash Aichhttp://social.msdn.microsoft.com/Profile/en-US/?user=Palash%20AichInvalid Parameter: Name handle ExceptionI am using VB.Net code to print barcode label in Zebra TLP 2844 printer. And the printer is connected to system by USB port. When i execute the code i get an error &quot;Invalid Parameter : Name handle&quot; in the line <span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'">outFile = </span><span style="font-size:12pt;color:#0600ff;line-height:115%;font-family:'Times New Roman','serif'">New</span><span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'"> FileStream(_SafeFileHandle, FileAccess.Write) . Can you please help me to rectify this.<br/><span style="font-size:x-small;font-family:Verdana">As this is a USB port So i shared the printer and used the UNC path. But still i get the error. Below is the complete code<br/><br/> <p class=MsoNormalCxSpFirst><strong><span style="font-size:small"><span style="font-family:Times New Roman">Name Spaces<br/></span></span></strong><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Imports System.IO <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Imports System.Runtime.InteropServices </span></p> <p class=MsoNormalCxSpMiddle><span style="font-size:small;font-family:Times New Roman"> </span><strong><span style="font-size:small"><span style="font-family:Times New Roman">Here is the button click code</span></span></strong></p> <p class=MsoNormalCxSpMiddle style="line-height:normal"><span style="font-size:small;font-family:Times New Roman"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Dim</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _print </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">as</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">new</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> ZebraPrint <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_print.StartWrite(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;//ComputerName/PrinterSharedName&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">dim</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _Text </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">as</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> = </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;Print test&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_print.Write(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;A30,120,0,4,2,1,N,&quot;&quot;&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> &amp; _Text &amp; </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;&quot;&quot;&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_print.EndWrite()</span></p> <p class=MsoNormalCxSpMiddle style="line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <div style="border-right:medium none;padding-right:0in;border-top:windowtext 1pt solid;padding-left:0in;padding-bottom:1pt;border-left:medium none;padding-top:1pt;border-bottom:windowtext 1pt solid;mso-element:para-border-div"> <p class=MsoNormalCxSpMiddle style="border-right:medium none;padding-right:0in;border-top:medium none;padding-left:0in;padding-bottom:0in;border-left:medium none;line-height:normal;padding-top:0in;border-bottom:medium none"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Class</span></p> </div> <p class=MsoNormalCxSpMiddle style="line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Class</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> ZebraPrint <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; Private constants &quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Const GENERIC_WRITE </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> = &amp;H40000000 <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Const OPEN_EXISTING </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> = </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">3</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; Private members &quot;<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _SafeFileHandle </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Microsoft.Win32.SafeHandles.SafeFileHandle<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _fileWriter </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> StreamWriter <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _outFile </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> FileStream </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; private structures &quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">&lt;StructLayout(LayoutKind.Sequential)&gt; _ <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Structure SECURITY_ATTRIBUTES <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> nLength </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> lpSecurityDescriptor </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> bInheritHandle </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Structure </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; com calls &quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Declare </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Function</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> CreateFile Lib </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;kernel32&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Alias </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;CreateFileA&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> (</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> lpFileName </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwDesiredAccess </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwShareMode </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, &lt;MarshalAs(UnmanagedType.Struct)&gt; </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByRef</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> lpSecurityAttributes </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> SECURITY_ATTRIBUTES, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwCreationDisposition </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwFlagsAndAttributes </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> hTemplateFile </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Microsoft.Win32.SafeHandles.SafeFileHandle </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; Public methods &quot;<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> StartWrite(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> printerPath </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Dim</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> SA </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> SECURITY_ATTRIBUTES </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_SafeFileHandle = CreateFile(printerPath, GENERIC_WRITE, </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">0</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, SA, OPEN_EXISTING, </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">0</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">0</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Try </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _outFile = </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">New</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> FileStream(_SafeFileHandle, FileAccess.Write) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter = </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">New</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> StreamWriter(_outFile) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            Catch ex </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Exception </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                System.Windows.Forms.MessageBox.Show(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;Can not find printer.&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;Warning&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Error</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, Windows.Forms.MessageBoxDefaultButton.Button1) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Try </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Write(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> rawLine </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            If _fileWriter IsNot </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Nothing</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Then</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter.WriteLine(rawLine) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> If </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> EndWrite() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            If _fileWriter IsNot </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Nothing</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Then</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter.Flush() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter.Close() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _outFile.Close() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> If </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            _SafeFileHandle.Close() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            _SafeFileHandle.Dispose() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'">    </span><span style="font-size:12pt;color:#0600ff;line-height:115%;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;line-height:115%;font-family:'Times New Roman','serif'">Class</span><span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'"> </span></span></span>Mon, 23 Nov 2009 13:18:51 Z2009-11-23T13:18:51Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/68b76165-a4d6-4f22-82d2-ccca60da6d26http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/68b76165-a4d6-4f22-82d2-ccca60da6d26Corbyhttp://social.msdn.microsoft.com/Profile/en-US/?user=CorbyActive Directory ChangePassword COM Exception error<p align=left><font face=Arial size=2>Doing an intranet web page for my company that allows to change their password.  I got it to work yesterday for about 3 minutes but then it stopped.  Here's the error:</font></p> <p align=left> </p> <p align=left>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Runtime.InteropServices.COMException (0x80070547): Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)</p> <p><span id=lblErrors style="z-index:108;left:118px;width:416px;position:absolute;top:269px"></span></p> <p align=left> </p> <p align=left>Here's my code.</p> <p align=left> </p><font size=2> <p></font><font color="#0000ff" size=2>string</font><font size=2> currentUserName = (((</font><font color="#0000ff" size=2>string</font><font size=2>)Context.User.Identity.Name).Split(</font><font color="#a31515" size=2>'\\'</font><font size=2>))[1];</p> <p></font><font color="#0000ff" size=2>string</font><font size=2> OldPassword = </font><font color="#0000ff" size=2>this</font><font size=2>.txtOldPassword.Text; </p> <p></font><font color="#0000ff" size=2>string</font><font size=2> NewPassword = </font><font color="#0000ff" size=2>this</font><font size=2>.txtNewPassword.Text;</p> <p>ChangePassword(currentUserName, </font><font color="#a31515" size=2>&quot;MyCompanyDomain&quot;</font><font size=2>, OldPassword, NewPassword);</font></p> <p align=left><font size=2></font> </p> <p align=left><font size=2></font> </p><font size=2><font color="#0000ff" size=2> <p>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> ChangePassword(</font><font color="#0000ff" size=2>string</font><font size=2> strLogin, </font><font color="#0000ff" size=2>string</font><font size=2> strRootPath, </font><font color="#0000ff" size=2>string</font><font size=2> strOldPasswd, </font><font color="#0000ff" size=2>string</font><font size=2> strNewPasswd)</p> <p>{</p></font><font size=2> <p></font><font color="#0000ff" size=2>try</p></font><font size=2> <p>{</p> <p>strRootPath = </font><font color="#2b91af" size=2>String</font><font size=2>.Format(</font><font color="#a31515" size=2>@&quot;LDAP://{0}&quot;</font><font size=2>, strRootPath);</font><font color="#008000" size=2></p></font><font size=2> <p></font><font color="#2b91af" size=2>DirectoryEntry</font><font size=2> objRootEntry = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>DirectoryEntry</font><font size=2>(strRootPath, strLogin, strOldPasswd, </font><font color="#2b91af" size=2>AuthenticationTypes</font><font size=2>.Secure);</p> <p></font><font color="#2b91af" size=2>DirectorySearcher</font><font size=2> objADSearcher = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>DirectorySearcher</font><font size=2>(objRootEntry);</p> <p>objADSearcher.Filter = </font><font color="#2b91af" size=2>String</font><font size=2>.Format(</font><font color="#a31515" size=2>@&quot;(&amp;(objectClass=user)(anr={0}))&quot;</font><font size=2>, strLogin);</p> <p></font><font color="#2b91af" size=2>SearchResult</font><font size=2> objResult = objADSearcher.FindOne();</p> <p></font><font color="#2b91af" size=2>DirectoryEntry</font><font size=2> objLoginEntry = (objResult != </font><font color="#0000ff" size=2>null</font><font size=2>) ? objResult.GetDirectoryEntry() : </font><font color="#0000ff" size=2>null</font><font size=2>;</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (objLoginEntry != </font><font color="#0000ff" size=2>null</font><font size=2>)</p> <p>{</p> <p></font><font color="#0000ff" size=2>object</font><font size=2> obj = objLoginEntry.InvokeSet(</font><font color="#a31515" size=2>&quot;ChangePassword&quot;</font><font size=2>, </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#0000ff" size=2>object</font><font size=2>[] { strOldPasswd, strNewPasswd });</p> <p>objLoginEntry.CommitChanges();</p> <p>obj = </font><font color="#0000ff" size=2>null</font><font size=2>;</p> <p>}</p> <p>objRootEntry = </font><font color="#0000ff" size=2>null</font><font size=2>;</p> <p>objADSearcher = </font><font color="#0000ff" size=2>null</font><font size=2>;</p> <p>objResult = </font><font color="#0000ff" size=2>null</font><font size=2>;</p> <p>objLoginEntry = </font><font color="#0000ff" size=2>null</font><font size=2>;</p> <p>}</p> <p></font><font color="#0000ff" size=2>catch</font><font size=2> (System.</font><font color="#2b91af" size=2>Exception</font><font size=2> abc)</p> <p>{</p> <p></font><font color="#0000ff" size=2>this</font><font size=2>.lblErrors.Text = abc.ToString();</p> <p>}</p></font> <p align=left>}</p> <p align=left>Anyone have any help on the error message?  I've been Googling answers for about 3 hours, but nothing seems to point me in the right direction...</p> <p align=left> </p> <p align=left>Thanks!</p> <p align=left> </p> <p align=left>-Corby-</font></p>Tue, 11 Dec 2007 14:43:28 Z2009-11-22T22:32:11Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ccb054c3-a72d-4d5d-a8ab-fc03c141e2d6http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ccb054c3-a72d-4d5d-a8ab-fc03c141e2d6NadiaDChttp://social.msdn.microsoft.com/Profile/en-US/?user=NadiaDCasp.net<span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small"><font size=2 color="#a31515"><font size=2 color="#a31515"> <p>how to modify .aspx page by using content page</p> </font></font></span><font size=2 color="#a31515"> <p> </p> </font></span> <p><span style="color:#a31515;font-size:x-small"></span></p>Sun, 22 Nov 2009 17:20:08 Z2009-11-22T18:33:48Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/b478ed90-acb2-4255-9f14-b1b4e67369aahttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/b478ed90-acb2-4255-9f14-b1b4e67369aaEng.Technohttp://social.msdn.microsoft.com/Profile/en-US/?user=Eng.TechnoProgress Barplease help me if the progress bar reached the maximum value how ican get it empty again and start progress after thatSat, 21 Nov 2009 11:54:57 Z2009-11-22T16:32:40Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/78223fb0-20c8-4443-9cbd-8d52b1d731bdhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/78223fb0-20c8-4443-9cbd-8d52b1d731bdmertkan65http://social.msdn.microsoft.com/Profile/en-US/?user=mertkan65NetworkStream.Length PropertyHi All,<br><br>I want to use this property but in MSDN it says &quot;This property is not currently supported and always throws a NotSupportedException.&quot;. When will it be supported? Can you suggest any other method or property?<br>Thu, 23 Nov 2006 08:20:56 Z2009-11-22T12:50:45Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/4587c454-2634-4495-819f-f60e5bb06061http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/4587c454-2634-4495-819f-f60e5bb06061Jitendra Pancholihttp://social.msdn.microsoft.com/Profile/en-US/?user=Jitendra%20PancholiVideo Creator<p>Hi,</p> <p>I want to make an application which can create video using its own intelligence.</p> <p>Explaination:<br/>User will provide number of images,text,audio sound, In short all the multimedia options as well as user will select the size of resulted video along with the type of the resulted video extention(.mov, .avi etc).<br/>Now the aplication will be selecting all the inputed resources and will create video ,which will be of specified size and having extention as per the users requirement.</p> <p>I'm confused that where do i start from and where can i find API which will help me going ahead.</p> <p>I need the API in asp.net-c#.</p> <p>Please help me out ASAP.</p> <p>Thanks in Advance....<br/> </p> Jitendra Pancholi (<a href="mailto:pancholi.jitu@gmail.com">pancholi.jitu@gmail.com</a>) Sat, 21 Nov 2009 19:47:27 Z2009-11-21T19:47:28Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/55e43ee4-a791-4b86-8a86-81138fb06573http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/55e43ee4-a791-4b86-8a86-81138fb06573Edeltraudhttp://social.msdn.microsoft.com/Profile/en-US/?user=EdeltraudVisual Studio 2008 Express Diagram, Modify <CustomLabel> at runtimeHow to modify CustomLabel at runtime. I could not find any example at the web, documentation or forums. <br/> The example of the behind code see below. How to translate HTML code in c# code?<br/> <br/> using System;<br/> using System.Collections.Generic;<br/> using System.Web;<br/> using System.Web.UI;<br/> using System.Web.UI.WebControls;<br/> using System.Web.UI.DataVisualization.Charting;<br/> <br/> public partial class _Default : System.Web.UI.Page<br/> {<br/>     <br/>     protected void Page_Load(object sender, EventArgs e)<br/>     {<br/>         FillData(0);<br/> <br/>         Chart1.Series[&quot;London&quot;].ChartType = SeriesChartType.Column; // Column für Säule <br/>         Chart1.Series[&quot;Berlin&quot;].ChartType = SeriesChartType.Column; // or Line für Linie<br/>     }<br/> <br/>     private void FillData(int month)<br/>     {<br/>         double plotY = month + 5.0;   <br/>         double plotY2 = month + 10.0; <br/>         if (Chart1.Series[&quot;London&quot;].Points.Count &gt; 0)<br/>         {<br/>         //    plotY = Chart1.Series[&quot;Series1&quot;].Points[Chart1.Series[&quot;Series1&quot;].Points.Count - 1].YValues[0];<br/>         //    plotY2 = Chart1.Series[&quot;Series2&quot;].Points[Chart1.Series[&quot;Series1&quot;].Points.Count - 1].YValues[0];<br/>             plotY = 5.0; <br/>             plotY2 = 7.0;<br/>         }<br/>     <br/>         for (int pointIndex = 0; pointIndex &lt; month; pointIndex++)<br/>         {<br/>             plotY = plotY + 1.0;<br/>             Chart1.Series[&quot;London&quot;].Points.AddY(plotY);<br/>            <br/>             plotY2 = plotY2 + 2.0;<br/>             Chart1.Series[&quot;Berlin&quot;].Points.AddY(plotY2);<br/>         }<br/>     }<br/>     protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)<br/>     {<br/>         int ausgw = System.Int32.Parse(DropDownList2.SelectedItem.Value);<br/>         FillData(ausgw);<br/>     }<br/> <br/>     <br/>     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)<br/>     {<br/>         int startmonth = System.Int32.Parse(DropDownList1.SelectedItem.Value);<br/>         // startmonth is index to selected month, eg. 1 -&gt; Jan, 2 = Feb.<br/>         // Is e.g. Feb selected, CustomLabel should start with Feb and enumerate to April<br/>         // if three month should be displayed (selected with DropDownList2)<br/>          <br/>         // C# Code for label assignment at runtime <br/> <br/>         .... ???<br/> <br/> <br/>         // this HTML part is copied from .aspx<br/>         //&lt;axisx linecolor=&quot;64, 64, 64, 64&quot; Title=&quot;Reported month&quot; &gt;<br/>         //                  &lt;labelstyle font=&quot;Trebuchet MS, 8.25pt, style=Bold&quot; /&gt;<br/>         //                  &lt;majorgrid linecolor=&quot;64, 64, 64, 64&quot; /&gt;<br/>         //              &lt;CustomLabels&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;0.5&quot; Text=&quot;Jan&quot; ToPosition=&quot;1.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;1.5&quot; Text=&quot;Feb&quot; ToPosition=&quot;2.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;2.5&quot; Text=&quot;Mar&quot; ToPosition=&quot;3.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;3.5&quot; Text=&quot;Apr&quot; ToPosition=&quot;4.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;4.5&quot; Text=&quot;May&quot; ToPosition=&quot;5.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;5.5&quot; Text=&quot;Jun&quot; ToPosition=&quot;6.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;6.5&quot; Text=&quot;Jul&quot; ToPosition=&quot;7.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;7.5&quot; Text=&quot;Aug&quot; ToPosition=&quot;8.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;8.5&quot; Text=&quot;Sep&quot; ToPosition=&quot;9.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;9.5&quot; Text=&quot;Oct&quot; ToPosition=&quot;10.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;10.5&quot; Text=&quot;Nov&quot; ToPosition=&quot;11.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;      <br/>         //                 &lt;asp:CustomLabel FromPosition=&quot;11.5&quot; Text=&quot;Dec&quot; ToPosition=&quot;12.5&quot; ForeColor=&quot;#FF0066&quot; /&gt;<br/>         //               &lt;/CustomLabels&gt;<br/>         //               &lt;MajorTickMark Interval=&quot;1&quot; IntervalOffset=&quot;Auto&quot; IntervalOffsetType=&quot;Auto&quot; IntervalType=&quot;Auto&quot; /&gt;<br/>         //&lt;/axisx&gt;<br/>     }<br/> }Sat, 21 Nov 2009 14:16:40 Z2009-11-21T14:16:40Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/4a7e84e6-a68b-41f1-b35d-b05c4fd911dfhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/4a7e84e6-a68b-41f1-b35d-b05c4fd911dfnevviinhttp://social.msdn.microsoft.com/Profile/en-US/?user=nevviinReceived an unexpected EOF or 0 bytes from the transport stream. from mailserverhi,<br/> <br/> I am reading the mails from mailserver using the POP and IMAP commands. While the reader is reading the response from the server , at certain point of time the it's not getting anything from the response . The applications is getting hanged .Please help me to solve this problem . i am postin this for the third time <br/> <br/>  Function GetMessage(ByVal sCommand As String, ByVal sslstream As SslStream, ByVal reader As StreamReader) As String<br/>         Dim tmpString As String = &quot;&quot;<br/>         Dim msg As String = &quot;&quot;<br/>         Try<br/> <br/>             sendcmd(sCommand, sslstream)<br/>             tmpString = reader.ReadLine()<br/>             If tmpString &lt;&gt; &quot;&quot; Then<br/>                 msg = msg &amp; tmpString &amp; vbCrLf<br/>             End If<br/>             While Not tmpString.StartsWith(sPrefix)<br/>                  tmpString = reader.ReadLine<br/>                 msg = msg &amp; tmpString &amp; vbCrLf<br/>             End While<br/>             If InStr(msg, &quot;BAD Could not parse command&quot;) &gt; 0 Then<br/>                 'appendFile(strErrPath, &quot;BAD command : command : &quot; &amp; sCommand &amp; Space(3) &amp; Date.Now)<br/>                 appendFile(strErrPath, &quot;Error in GetMessage, BAD command : command : &quot; &amp; sCommand &amp; Space(3) * &quot;User: &quot; &amp; UserName &amp; Date.Now)<br/>                 'MsgBox(&quot;BAD GETMESSAGE&quot;)<br/>             End If<br/>         Catch ex As Exception<br/>             appendFile(strErrPath, &quot;Error in GetMessage, BAD command : command : &quot; &amp; sCommand &amp; Space(3) * &quot;User: &quot; &amp; UserName &amp; ex.Message &amp; Date.Now)<br/>         End Try<br/> <br/>         Return msg<br/>     End Function<br/> <br/> <br/> thanks &amp; regards<br/><hr class="sig">Thanks &amp; Regards http://www.keralapavilion.com/Sat, 21 Nov 2009 12:54:21 Z2009-11-21T12:54:21Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ece6bba8-94b0-4000-80e3-75bc82c9f8b1http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ece6bba8-94b0-4000-80e3-75bc82c9f8b1Irshad_iphttp://social.msdn.microsoft.com/Profile/en-US/?user=Irshad_ipHow to send the SMS using vb.net<p>Hello Friends</p> <p>        i developing windows desktop application in vb.net  for sending SMS through internet, but i have no idea about that. so plz help me for writing this code.</p> <p> </p> <p>Irshad </p> <p> </p>Mon, 27 Nov 2006 12:42:23 Z2009-11-21T11:23:57Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/c5085eb1-21bc-4fe1-a9db-42f7eb7ebbc7http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/c5085eb1-21bc-4fe1-a9db-42f7eb7ebbc7hi dbhttp://social.msdn.microsoft.com/Profile/en-US/?user=hi%20dbRestaring iis server<p>hi all<br/>after creating a merge replication on the sql server 2005 and sqlce in the vstudio8 a get an error on my Emulator (pc pocket 2003) <br/><strong>an error has ocurred on the computer runnig iis, try restarting the iis server</strong></p> <p>so what can i do, and what happened to get that message because the application was runnig befoure...</p> <p>thank you all</p>Sat, 21 Nov 2009 10:01:59 Z2009-11-21T10:01:59Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/49862d0b-297a-4beb-8a22-76257a0c4642http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/49862d0b-297a-4beb-8a22-76257a0c4642MrRogerhttp://social.msdn.microsoft.com/Profile/en-US/?user=MrRogerOUI Extended ethertype packet on RAW socketsWhenever I try and find out about using RAW sockets all I find is information relating to Sec issues, building and sending IP packets, and the restrictions that Windows places on these.<br/> <br/> I need to send and recieve OUI extended ethertype packets for working with networked devices. Is it possible to do this from a user space application using the .Net framework?<br/> <br/> Does windows try to block the use of such protocols?<br/> <br/>Sat, 21 Nov 2009 01:33:52 Z2009-11-21T01:33:53Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/0a121b15-78c4-4b4e-aaa9-dfe424a99a92http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/0a121b15-78c4-4b4e-aaa9-dfe424a99a92Accord CM2http://social.msdn.microsoft.com/Profile/en-US/?user=Accord%20CM2Deploy WCF to IIS 7.5 (Win 2008 R2) Hi All,<br><br>Just installed the Win Server 2008 R2. I can't deploy the WCF project to IIS7.5 througth VS2008 (http publish). Does anyone know how to configure IIS 7.5 to support it?<br><br>Eric Wong<br><hr class="sig">CM2Tue, 13 Jan 2009 16:58:07 Z2009-11-21T00:43:37Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/3cd2dfa0-f057-45de-84ba-f1d37d04e848http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/3cd2dfa0-f057-45de-84ba-f1d37d04e848CoachMeFithttp://social.msdn.microsoft.com/Profile/en-US/?user=CoachMeFitHow to prevent users from changing Local Area Connection settings.I have found user poking around with Local Area Connection , changing settings. I also have some computers setup for Static IP address without Gateway to block internet Access. User always changing it to DHCP to get to internet. I don't want to disable the Network Card because computer use application that need Network to have an IP address. So How do I prevent users from changing Local Area Connection settings?<br/><br/>Wed, 18 Nov 2009 11:54:22 Z2009-11-20T14:18:16Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a4f572c2-99ea-4574-8c54-9124e2232c72http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a4f572c2-99ea-4574-8c54-9124e2232c72Pieterthttp://social.msdn.microsoft.com/Profile/en-US/?user=PietertNetTcpBinding over internetYet another NetTcpBinding over internet question.<br/> But a theoretical one.<br/> <br/> Currently our model needs callbacks (duplex). We communicate over the internet. This left us with the choice between the WSDualHttpBinding and the NetTcpBinding. We've tested and evaluated them both, and concluded NetTcpBinding performed better and had no problems with our clients firewalls. So we went for the NetTcpBinding.<br/> <br/> Now all over the web you read NetTcpBinding is used for Intr<strong>a</strong> net scenario's and comments like &quot;don't use NetTcp for internet scenario's&quot;. But nowhere it states <span style="text-decoration:underline"><strong><em>WHY </em> </strong> </span> (except for not being compatible with the WS standard leaving you with .NET compatibility only, not a problem in our case). After consulting an expert he told me NetTcp is easy to bring down using DoS by using up connections. But, is this not also true for WsDualHttp (when using sessions)...?<br/> <br/> For performance reasons the clients have 1 proxy alive, for 10 minutes. When they make more then 1 call at a time (multithreated) new proxies are created but they are closed after the calls are done (where as that 1 proxy won't be closed and keeps the session for 10 minutes). After 10 minutes the proxy will be idle, if it is afther that time again it is recreated. This has worked without a single problem for the past few months. <br/> <br/> - NetTcpBinding has served us well with 10-20 simualtanious clients on a server. But when we take the software in production (hoping for a 1000+ customers), will it start causing problems (offcourse taking in account changed settings, higher limits etc and server capacity) and force us to move to WsHttp? <br/> - Is it recommended to factor out the callbacks and let client software periodically check for updates (our code is threatsafe and never caused a problem yet...)? <br/> - If not, why would WsDualHttp (which in my believe is nothing more than a kind of hack to WsHttp (is it not?)) serve us better?<br/> - Why should NetTcpBinding only be used over a LAN?Sat, 14 Nov 2009 16:02:34 Z2009-11-20T12:38:25Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/659278d2-f736-4783-9f8a-058d7620a020http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/659278d2-f736-4783-9f8a-058d7620a020sahil goyalhttp://social.msdn.microsoft.com/Profile/en-US/?user=sahil%20goyalHandshake with C#hiii<br/> <br/>              I m working in C# and i m sending char data through serial port to printer.my printer's memory and speed is less so,when i send bulk of data to printer then its memory or line goes full. that time i want  it will show me some message on my pc till then printer is busy.i m using handshake.readytosend but i cudn't get my result.plz help.<br/> <br/> MY CODE IS:-<br/> <br/> using System;<br/> using System.Collections.Generic;<br/> using System.ComponentModel;<br/> using System.Data;<br/> using System.Drawing;<br/> using System.Text;<br/> using System.IO.Ports;<br/> using System.Windows.Forms;<br/> <br/> namespace portsend<br/> {<br/>     public partial class Form1 : Form<br/>     {<br/>         SerialPort port = new SerialPort(&quot;COM1&quot;, 1200, Parity.None, 8, StopBits.One);<br/> <br/>         public Form1()<br/>         {<br/>             InitializeComponent();<br/>             port.Open();<br/>         }<br/>         <br/>         private void button1_Click(object sender, EventArgs e)<br/>         {<br/>            <br/>             string s = &quot;&quot;;<br/>             char[] arr = new char[] { '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n', '+', '0', '0', '0', '1', '0', '5', '\r', '\n'};<br/>             //char[] arr = new char[] { '+', '0', '0', '0', '1', '0', '5', '\r', '\n'};<br/> <br/> <br/>            <br/>            // {<br/>                // MessageBox.Show(&quot;handshake mode is open&quot;);<br/>            // }<br/>            // else<br/>                // MessageBox.Show(&quot;port is not handshake&quot;);<br/> <br/>                 //if (port.RtsEnable == true)<br/>                 //{<br/>                 //    MessageBox.Show(&quot;handshake mode is open&quot;);<br/>                 //}<br/>                 //else<br/>                 //MessageBox.Show(&quot;port is not handshake&quot;);<br/>             //port.RtsEnable.Equals(true);<br/>             try<br/>             {<br/>                 port.Handshake = Handshake.RequestToSend;<br/>                 if (port.CtsHolding == false)<br/>                 {<br/>                     for (int i = 0; i &lt; arr.Length; i++)<br/>                     {<br/>                         //port.DtrEnable.Equals(true);<br/> <br/> <br/>                         s = arr[i].ToString();<br/>                         port.Write(s);<br/> <br/>                         //textBox1.Text = s.Length.ToString();<br/>                         //port.d<br/>                     }<br/>                 }<br/>                 else<br/>                 {<br/>                     MessageBox.Show(&quot;terminal not ready&quot;);<br/> <br/>                 }<br/>             }<br/>             catch (Exception ex)<br/>             {<br/>                 MessageBox.Show(ex.Message);<br/>             }Fri, 20 Nov 2009 10:46:24 Z2009-11-20T10:46:25Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/d5152857-7695-4c9e-a12d-ea7f386ff11dhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/d5152857-7695-4c9e-a12d-ea7f386ff11dalrazgihttp://social.msdn.microsoft.com/Profile/en-US/?user=alrazgiHelp mmmmetro to store the :<br/><br/>1-Console.WriteLine(&quot;Message received from {0}:&quot;, tmpRemote.ToString());<br/>2-   Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));<br/><br/>in lable1 and lable2 repectively <br/>Fri, 20 Nov 2009 00:18:04 Z2009-11-20T08:22:04Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/1aa71b53-959a-4173-b88f-10f2dc286705http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/1aa71b53-959a-4173-b88f-10f2dc286705nevviinhttp://social.msdn.microsoft.com/Profile/en-US/?user=nevviinreader is not able to read stream and application is going for a halt while reading from a mailserver ? &lt;!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:&quot;&quot;; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:&quot;Times New Roman&quot;; mso-fareast-font-family:&quot;Times New Roman&quot;;} @page Section1 {size:8.5in 11.0in; margin:1.0in .5in 1.0in .5in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --&gt; <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">Hi all,</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">I am developing a vb.net desktop application that reads mails from the<span>  </span> mailserver using pop and imap .</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">The application is almost fnished .The problem is the some time when a command is send to retrieve a mail using GetMessage() functions the applications is going to a halt </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">So I tried to run the the code in debug mode and ran line by line <span> </span> . </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">What I noticed is in the while loop in GetMessage() function is </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">While</span> <span style="color:blue">Not</span> tmpString.StartsWith(sPrefix)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> tmpString = reader.ReadLine</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> msg = msg &amp; tmpString &amp; vbCrLf</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">End</span> <span style="color:blue">While</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">The reader reads line by line at certain point of time it got hangs</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">Some times it ill catch an exception and give an error . I am pasting the exception below</span></p> <p class=MsoNormal>&quot;Received an unexpected EOF or 0 bytes from the transport stream&quot;</p> <p class=MsoNormal> </p> <p class=MsoNormal>But some times the applications will hang and go for a halt <span> </span> .This applications has to run 24/7 .So if it hangs in the night or it will be problem .</p> <p class=MsoNormal> </p> <p class=MsoNormal>What I want is if the reader is not able to read from the stream after certain time period . the control has to be removed from the reader and the function has to return a message . I am new to this the network level applications and I am running shot of time</p> <p class=MsoNormal>So I am in big trouble . If anybody knows this problem please help me</p> <p class=MsoNormal> </p> <p class=MsoNormal>I have pasted the code briefly so that you can get an idea about the program<span style="font-size:10pt;font-family:'Courier New';color:blue"></span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">Public</span> <span style="font-size:10pt;font-family:'Courier New'"> <span style="color:blue">Sub</span> connect()</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> objTCP <span style="color:blue">As</span> <span style="color:blue">New</span> TcpClient</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> sslstream <span style="color:blue">As</span> Net.Security.SslStream</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> reader <span style="color:blue">As</span> StreamReader = <span style="color:blue">Nothing</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Try</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> objTCP.Connect(IMAPserver, Port)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> objTCP.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 5000) <span style="color:green">' 5s timeout</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> sslstream = <span style="color:blue">New</span> Net.Security.SslStream(objTCP.GetStream())</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> sslstream.AuthenticateAsClient(IMAPserver) <span style="color:green">' authenticate as client<span>  </span> GMAIL </span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> AuthStatus = sslstream.IsAuthenticated</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> reader = <span style="color:blue">New</span> IO.StreamReader(sslstream)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin-left:0.5in;text-indent:0.5in"><span style="font-size:10pt;font-family:'Courier New'">fetch()</span></p> <p class=MsoNormal style="margin-left:0.5in;text-indent:0.5in"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">End</span> <span style="color:blue">If</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> objTCP.Close()</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> reader.Close()</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> sslstream.Close()</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Catch</span> ex <span style="color:blue">As</span> Exception</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> appendFile(strErrPath, <span style="color:#a31515">&quot;Exception in IMAPClass Connect &quot;</span> &amp; ex.Message.ToString &amp; <span style="color:#a31515">&quot; &quot;</span> &amp; <span style="color:blue">Date</span> .Now)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">End</span> <span style="color:blue">Try</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>    </span> <span style="color:blue">End</span> <span style="color:blue">Sub</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <span style="font-size:10pt;font-family:'Courier New';color:blue"><br style="page-break-before:always"> </span> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">Sub</span> <span style="font-size:10pt;font-family:'Courier New'"> fetchTest(<span style="color:blue">ByVal</span> SslStream <span style="color:blue">As</span> SslStream, <span style="color:blue">ByVal</span> reader <span style="color:blue">As</span> StreamReader)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> intMailsRead <span style="color:blue">As</span> <span style="color:blue">Integer</span> = 0</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> intIndex <span style="color:blue">As</span> <span style="color:blue">Integer</span> = 40</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> strHeader <span style="color:blue">As</span> <span style="color:blue">String</span> = <span style="color:#a31515">&quot;&quot;</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> strBody <span style="color:blue">As</span> <span style="color:blue">String</span> = <span style="color:#a31515">&quot;&quot;</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span>            </span> strHeader = GetMessage(<span style="color:#a31515">&quot;FETCH &quot;</span> &amp; intIndex &amp; <span style="color:#a31515">&quot; RFC822.HEADER&quot;</span> , SslStream, <span>    </span> reader)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span>            </span> strBody = GetMessage(<span style="color:#a31515">&quot;FETCH &quot;</span> &amp; intIndex &amp; <span style="color:#a31515">&quot; BODY[text]&quot;</span> , SslStream, reader)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>     </span> <span>       </span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Catch</span> ex <span style="color:blue">As</span> Exception</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> appendFile(strErrPath, <span style="color:#a31515">&quot; error in fetch&quot;</span> &amp; ex.Message.ToString() &amp; <span style="color:#a31515">&quot;<span>  </span> &quot;</span> &amp; EmailId &amp; <span style="color:#a31515">&quot;<span>  </span> &quot;</span> &amp; <span style="color:blue">Date</span> .Now)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">End</span> <span style="color:blue">Try</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>    </span> <span style="color:blue">End</span> <span style="color:blue">Sub</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">Function</span> <span style="font-size:10pt;font-family:'Courier New'"> GetMessage(<span style="color:blue">ByVal</span> sCommand <span style="color:blue">As</span> <span style="color:blue">String</span> , <span style="color:blue">ByVal</span> sslstream <span style="color:blue">As</span> SslStream, <span style="color:blue">ByVal</span> reader <span style="color:blue">As</span> StreamReader) <span style="color:blue">As</span> <span style="color:blue">String</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> tmpString <span style="color:blue">As</span> <span style="color:blue">String</span> = <span style="color:#a31515">&quot;&quot;</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Dim</span> msg <span style="color:blue">As</span> <span style="color:blue">String</span> = <span style="color:#a31515">&quot;&quot;</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Try</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> sendcmd(sCommand, sslstream)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> tmpString = reader.ReadLine()</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">If</span> tmpString &lt;&gt; <span style="color:#a31515">&quot;&quot;</span> <span style="color:blue">Then</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> msg = msg &amp; tmpString &amp; vbCrLf</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">End</span> <span style="color:blue">If</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">While</span> <span style="color:blue">Not</span> tmpString.StartsWith(sPrefix)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> <span style="color:blue">If</span> reader.EndOfStream = <span style="color:blue">True</span> <span style="color:blue">Then</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>          </span> <span>          </span> <span style="color:blue">Exit</span> <span style="color:blue">While</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> <span style="color:blue">End</span> <span style="color:blue">If</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> tmpString = reader.ReadLine</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> msg = msg &amp; tmpString &amp; vbCrLf</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">End</span> <span style="color:blue">While</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">If</span> InStr(msg, <span style="color:#a31515">&quot;BAD Could not parse command&quot;</span> ) &gt; 0 <span style="color:blue">Then</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>                </span> <span style="color:green">'MsgBox(&quot;BAD GETMESSAGE&quot;)</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">End</span> <span style="color:blue">If</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Catch</span> ex <span style="color:blue">As</span> Exception</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> appendFile(strErrPath, <span style="color:#a31515">&quot;Error in GetMessage, BAD command : command : &quot;</span> &amp; sCommand &amp; Space(3) * <span style="color:#a31515">&quot;User: &quot;</span> &amp; UserName &amp; ex.Message &amp; <span style="color:blue">Date</span> .Now)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">End</span> <span style="color:blue">Try</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Return</span> msg</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>    </span> <span style="color:blue">End</span> <span style="color:blue">Function</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>  </span> <span style="color:blue">Public</span> <span style="color:blue">Sub</span> sendcmd(<span style="color:blue">ByVal</span> strCmd <span style="color:blue">As</span> <span style="color:blue">String</span> , <span style="color:blue">ByVal</span> sslstream <span style="color:blue">As</span> SslStream)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Try</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">Dim</span> Data <span style="color:blue">As</span> <span style="color:blue">String</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> <span style="color:blue">Dim</span> SzData() <span style="color:blue">As</span> <span style="color:blue">Byte</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> Data = GetPrefix() &amp; <span style="color:#a31515">&quot; &quot;</span> &amp; strCmd &amp; vbCrLf</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> SzData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> sslstream.Write(SzData, 0, SzData.Length)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">Catch</span> ex <span style="color:blue">As</span> Exception</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> appendFile(strErrPath, <span style="color:#a31515">&quot;Exception in sendcmd &quot;</span> &amp; ex.Message.ToString &amp; <span style="color:blue">Date</span> .Now)</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>  </span> <span>      </span> <span style="color:blue">End</span> <span style="color:blue">Try</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>    </span> <span style="color:blue">End</span> <span style="color:blue">Sub</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>    </span> <span style="color:blue">Private</span> <span style="color:blue">Function</span> GetPrefix() <span style="color:blue">As</span> <span style="color:blue">String</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> iPrefix = iPrefix + 1</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> sPrefix = iPrefix.ToString</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">While</span> sPrefix.Length &lt; 3</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>            </span> sPrefix = <span style="color:#a31515">&quot;0&quot;</span> &amp; sPrefix</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> <span style="color:blue">End</span> <span style="color:blue">While</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>        </span> sPrefix = <span style="color:#a31515">&quot;A&quot;</span> &amp; sPrefix</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>   </span> <span>     </span> <span style="color:blue">Return</span> sPrefix</span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New'"><span>    </span> <span style="color:blue">End</span> <span style="color:blue">Function</span> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue"> </span></p> <p class=MsoNormal><span style="font-size:10pt;font-family:'Courier New';color:blue">Thanks and regards</span></p><hr class="sig">Thanks &amp; Regards http://www.keralapavilion.com/Fri, 20 Nov 2009 08:17:56 Z2009-11-20T08:17:56Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/741d368d-657b-4e4d-b778-6286119731b9http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/741d368d-657b-4e4d-b778-6286119731b9pahualhttp://social.msdn.microsoft.com/Profile/en-US/?user=pahualTimeout doesn't work and thread hang when calling webservice in c#<p>I have encountered hanging when doing a webservice call using SoapHttpClientProtocol<br/>The timeout is set but didn't work and the thread hang forever.<br/>Does anyone met the same issue before?<br/><br/>stack is as below:<br/>is dump call stack:<br/>  41  Id: 13b8.17ac Suspend: 0 Teb: 7ffd4000 Unfrozen<br/>ChildEBP RetAddr  Args to Child              <br/>00b5dc88 7c827d19 77e6202c 00000001 00b5dcd8 ntdll!KiFastSystemCallRet (FPO: [0,0,0]) [d:\nt\base\ntos\rtl\i386\userdisp.asm @ 545]<br/>00b5dc8c 77e6202c 00000001 00b5dcd8 00000000 ntdll!NtWaitForMultipleObjects+0xc (FPO: [5,0,0]) [d:\nt\base\ntdll\daytona\obj\i386\usrstubs.asm @ 2363]<br/>00b5dd34 79f4c88a 00000001 00b5df74 00000001 kernel32!WaitForMultipleObjectsEx+0x11a (FPO: [Non-Fpo]) (CONV: stdcall) [d:\nt\base\win32\client\synch.c @ 1521]<br/>00b5dd9c 79f4c4bb 00000001 00b5df74 00000001 mscorwks!WaitForMultipleObjectsEx_SO_TOLERANT+0x6f (FPO: [Non-Fpo]) (CONV: stdcall) [f:\dd\ndp\clr\src\vm\threads.cpp @ 4512]<br/>00b5ddbc 79f4c5c4 00000001 00b5df74 00000001 mscorwks!Thread::DoAppropriateAptStateWait+0x3c (FPO: [Non-Fpo]) (CONV: thiscall) [f:\dd\ndp\clr\src\vm\threads.cpp @ 4543]<br/>00b5de40 79f4c659 00000001 00b5df74 00000001 mscorwks!Thread::DoAppropriateWaitWorker+0x13c (FPO: [Non-Fpo]) (CONV: thiscall) [f:\dd\ndp\clr\src\vm\threads.cpp @ 4671]<br/>00b5de90 79f159e8 00000001 00b5df74 00000001 mscorwks!Thread::DoAppropriateWait+0x40 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\dd\ndp\clr\src\vm\threads.cpp @ 4123]<br/>00b5df94 792b687f 00000000 00000000 0df089e4 mscorwks!WaitHandleNative::CorWaitOneNative+0x156 (FPO: [Non-Fpo]) (CONV: fastcall) [f:\dd\ndp\clr\src\vm\comwaithandle.cpp @ 150]<br/>00b5dfb0 792b6835 00000000 00000000 00000000 mscorlib_ni!System.Threading.WaitHandle.WaitOne(Int64, Boolean)+0x2f (Managed) [f:\dd\ndp\clr\src\BCL\System\Threading\WaitHandle.cs @ 182]<br/>00b5dfc8 7a57ef33 00000000 00000000 00000000 mscorlib_ni!System.Threading.WaitHandle.WaitOne(Int32, Boolean)+0x25 (Managed) [f:\dd\ndp\clr\src\BCL\System\Threading\WaitHandle.cs @ 144]<br/>00b5e000 7aa9d585 00000000 00000000 00000000 System_ni!System.Net.LazyAsyncResult.WaitForCompletion(Boolean)+0xd3 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\_LazyAsyncResult.cs @ 493]<br/>00b5e044 7a593cdd 00000000 00000000 00000000 System_ni!System.Net.Security.SslState.CheckEnqueueRead(Byte[], Int32, Int32, System.Net.AsyncProtocolRequest)+0x509865 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\SecureProtocols\_SslState.cs @ 1238]<br/>00b5e06c 7a593a6b 00000000 00000000 00000000 System_ni!System.Net.Security._SslStream.StartReading(Byte[], Int32, Int32, System.Net.AsyncProtocolRequest)+0x6d (Managed) [f:\dd\ndp\fx\src\Net\System\Net\SecureProtocols\_SslStream.cs @ 611]<br/>00b5e0b4 7a96616c 00000000 00000000 00000000 System_ni!System.Net.Security._SslStream.ProcessRead(Byte[], Int32, Int32, System.Net.AsyncProtocolRequest)+0x6b (Managed) [f:\dd\ndp\fx\src\Net\System\Net\SecureProtocols\_SslStream.cs @ 553]<br/>00b5e0ec 7a58967b 00000000 00000000 00000000 System_ni!System.Net.TlsStream.Read(Byte[], Int32, Int32)+0x58 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\_TLSstream.cs @ 110]<br/>00b5e108 7a58936a 00000000 00000000 00000000 System_ni!System.Net.PooledStream.Read(Byte[], Int32, Int32)+0x1b (Managed) [f:\dd\ndp\fx\src\Net\System\Net\_PooledStream.cs @ 454]<br/>00b5e15c 7a5891da 00000000 00000000 00000000 System_ni!System.Net.Connection.SyncRead(System.Net.HttpWebRequest, Boolean, Boolean)+0x12a (Managed) [f:\dd\ndp\fx\src\Net\System\Net\_Connection.cs @ 3051]<br/>00b5e178 7a58916b 00000000 00000000 00000000 System_ni!System.Net.Connection.PollAndRead(System.Net.HttpWebRequest, Boolean)+0x5a (Managed) [f:\dd\ndp\fx\src\Net\System\Net\_Connection.cs @ 2990]<br/>00b5e1b4 7a589002 00000000 00000000 00000000 System_ni!System.Net.ConnectStream.PollAndRead(Boolean)+0x1b (Managed) [f:\dd\ndp\fx\src\Net\System\Net\_ConnectStream.cs @ 2675]<br/>00b5e1b4 7a588f16 00000000 00000000 00000000 System_ni!System.Net.HttpWebRequest.EndWriteHeaders(Boolean)+0xa2 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\HttpWebRequest.cs @ 3941]<br/>00b5e1c0 7a588ad1 00000000 00000000 00000000 System_ni!System.Net.HttpWebRequest.WriteHeadersCallback(System.Net.WebExceptionStatus, System.Net.ConnectStream, Boolean)+0x16 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\HttpWebRequest.cs @ 2934]<br/>00b5e21c 7a586e42 00000000 00000000 00000000 System_ni!System.Net.ConnectStream.WriteHeaders(Boolean)+0x2d1 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\_ConnectStream.cs @ 2670]<br/>00b5e248 7a58822e 00000000 00000000 00000000 System_ni!System.Net.HttpWebRequest.EndSubmitRequest()+0x82 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\HttpWebRequest.cs @ 3873]<br/>00b5e25c 7a588107 00000000 00000000 00000000 System_ni!System.Net.HttpWebRequest.CheckDeferredCallDone(System.Net.ConnectStream)+0x4e (Managed) [f:\dd\ndp\fx\src\Net\System\Net\HttpWebRequest.cs @ 1893]<br/>00b5e29c 65dda7e5 00000000 00000000 00000000 System_ni!System.Net.HttpWebRequest.GetResponse()+0x1b7 (Managed) [f:\dd\ndp\fx\src\Net\System\Net\HttpWebRequest.cs @ 1972]<br/>00b5e2cc 65dde855 00000000 00000000 00000000 System_Web_Services_ni!System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(System.Net.WebRequest)+0xd5 (Managed) [f:\dd\ndp\fx\src\Services\Web\System\Web\Services\Protocols\ClientProtocol.cs @ 444]<br/>00b5e310 65e098c5 00000000 00000000 00000000 System_Web_Services_ni!System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(System.Net.WebRequest)+0x5 (Managed) [f:\dd\ndp\fx\src\Services\Web\System\Web\Services\Protocols\ClientProtocol.cs @ 869]<br/>00b5e310 1e6460ae 00000000 00000000 00000000 System_Web_Services_ni!System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(System.String, System.Object[])+0xad (Managed) [f:\dd\ndp\fx\src\Services\Web\System\Web\Services\Protocols\SoapClientProtocol.cs @ 306]</p>Mon, 16 Nov 2009 08:11:30 Z2009-11-20T06:39:28Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/2f0f5bbe-38c6-4d4d-b126-795c4cb31643http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/2f0f5bbe-38c6-4d4d-b126-795c4cb31643alrazgihttp://social.msdn.microsoft.com/Profile/en-US/?user=alrazgiClinet-Server problem description :<br/>assume i have four servers each server have one clinet  ,when any clinet connect with any server send message ,it will be send to server that connect with him ,then server in turn send the message to all server that connect with it ,and the servers send the message to it's clinets <br/>only using UDP <br/>using Windows Application not consoleFri, 20 Nov 2009 00:24:27 Z2009-11-20T00:24:28Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/9a6179ad-2385-43e9-aa88-330c20daaa4chttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/9a6179ad-2385-43e9-aa88-330c20daaa4cKartheechidambaramhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kartheechidambarambroken file upload in ftp<p>hi<br/>      doing a project in ftp. while uploading a file when the network gets disconnected ,while resuming upload it must start from the place where the last byte was written im using <strong>ftpwebrequest class but it gives me error &quot;File unavailable error code 550&quot;</strong> below is my code.<br/><br/><br/><span style="font-size:x-small"><font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">if</span><span style="font-size:x-small"> (System.IO.</span><span style="font-size:x-small;color:#008080">File</span><span style="font-size:x-small">.Exists(file_to_upload)) <p>{</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008000">//FtpWebResponse response;</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff">try</span></p> <span style="font-size:x-small"> <p>{</p> <font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff">int</span><span style="font-size:x-small"> Appendinglength = 0;<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">int</span><span style="font-size:x-small"> TotalLength = 0; <p>pointer = 0;</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">long</span><span style="font-size:x-small"> FTPFilesize = 0;<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008080">FileInfo</span><span style="font-size:x-small"> finfo = </span><span style="font-size:x-small;color:#0000ff">new</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#008080">FileInfo</span><span style="font-size:x-small">(file_to_upload);<font size=2> <p>TotalLength =</p> </font></span></p> <p><span style="font-size:x-small;color:#008080">Convert</span><span style="font-size:x-small">.ToInt32(finfo.Length);<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008080">FtpWebRequest</span><span style="font-size:x-small"> ftprequest;<font size=2> <p>ftprequest = (</p> </font></span></p> <p><span style="font-size:x-small;color:#008080">FtpWebRequest</span><span style="font-size:x-small">)</span><span style="font-size:x-small;color:#008080">FtpWebRequest</span><span style="font-size:x-small">.CreateDefault(</span><span style="font-size:x-small;color:#0000ff">new</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#008080">Uri</span><span style="font-size:x-small">(</span><span style="font-size:x-small;color:#800000">&quot;ftp://&quot;</span><span style="font-size:x-small"> + IP + </span><span style="font-size:x-small;color:#800000">&quot;/&quot;</span><span style="font-size:x-small"> + finfo.Name));<font size=2> <p>ftprequest.Credentials =</p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">new</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#008080">NetworkCredential</span><span style="font-size:x-small">(Uname, Pwd);<font size=2> <p>ftprequest.UseBinary =</p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">true</span><span style="font-size:x-small">;<font size=2> <p>ftprequest.KeepAlive =</p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">false</span><span style="font-size:x-small">;<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008000">//if (ISFtpFileExists(finfo.Name, out FTPFilesize))</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">//{</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">// //ftprequest.Method = WebRequestMethods.Ftp.AppendFile;</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">// ftprequest.Method = WebRequestMethods.Ftp.UploadFile;</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">//}</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">//else</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">//{</span></p> <span style="font-size:x-small"><font size=2> <p>ftprequest.Method =</p> </font></span> <p><span style="font-size:x-small;color:#008080">WebRequestMethods</span><span style="font-size:x-small">.</span><span style="font-size:x-small;color:#008080">Ftp</span><span style="font-size:x-small">.UploadFile;<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008000">//}</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">//ftprequest.ContentLength = finfo.Length - FTPFilesize;</span></p> <span style="font-size:x-small"><font size=2> <p>ftprequest.UsePassive =</p> </font></span> <p><span style="font-size:x-small;color:#0000ff">false</span><span style="font-size:x-small">; <p>ToWriteStream = ftprequest.GetRequestStream();</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008000">//response = (FtpWebResponse)ftprequest.GetResponse();</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008080">FileStream</span><span style="font-size:x-small"> fst = </span><span style="font-size:x-small;color:#0000ff">new</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#008080">FileStream</span><span style="font-size:x-small">(file_to_upload, </span><span style="font-size:x-small;color:#008080">FileMode</span><span style="font-size:x-small">.Open);<font size=2> <p>fst.Seek(FTPFilesize,</p> </font></span></p> <p><span style="font-size:x-small;color:#008080">SeekOrigin</span><span style="font-size:x-small">.Begin);<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">byte</span><span style="font-size:x-small">[] buffer = </span><span style="font-size:x-small;color:#0000ff">new</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff">byte</span><span style="font-size:x-small">[bufferLength]; <p>pointer = fst.Read(buffer, 0, bufferLength);</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">while</span><span style="font-size:x-small"> (pointer != 0) <p>{</p> <p>ToWriteStream.Write(buffer, 0, pointer);</p> <p>Appendinglength += pointer;</p> <p>PrgUpdate(CalculateProgress(Appendinglength, TotalLength));</p> <p>pointer = fst.Read(buffer, 0, bufferLength);</p> <p>}</p> <p>ToWriteStream.Close();</p> <p>fst.Close();</p> <p>}</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">catch</span><span style="font-size:x-small"> (</span><span style="font-size:x-small;color:#008080">WebException</span><span style="font-size:x-small"> ex) <p>{</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008080">FtpWebResponse</span><span style="font-size:x-small"> response = ex.Response </span><span style="font-size:x-small;color:#0000ff">as</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#008080">FtpWebResponse</span><span style="font-size:x-small">; <p>Exoccur(response.StatusCode.ToString());</p> <p>Exoccur(ex.Message);</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008000">//response.Close();</span></p> <span style="font-size:x-small"> <p>}</p> <font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff">catch</span><span style="font-size:x-small"> (</span><span style="font-size:x-small;color:#008080">Exception</span><span style="font-size:x-small"> ex) <p>{</p> <p>Exoccur(ex.Message);</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">return</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff">false</span><span style="font-size:x-small">; <p>}</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">finally</span></p> <span style="font-size:x-small"> <p>{</p> <font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">//ToWriteStream.Close();</span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#008000">////response.Close();</span></p> <span style="font-size:x-small"> <p>}</p> <p>}</p> <font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff">else</span></p> <span style="font-size:x-small"> <p>{</p> <font size=2> <p>Exoccur(</p> </font></span> <p><span style="font-size:x-small;color:#800000">&quot;File Doesnt occur&quot;</span><span style="font-size:x-small">); <p> </p> <p>}</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff">return</span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff">true</span><span style="font-size:x-small">; <p>}</p> </span></p>Fri, 18 Sep 2009 10:50:11 Z2009-11-19T22:30:55Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/879f13d7-24e6-4a0f-b396-627e9da25fc1http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/879f13d7-24e6-4a0f-b396-627e9da25fc1nbnbhttp://social.msdn.microsoft.com/Profile/en-US/?user=nbnbBugs in System.Net.Mail.MailMessage (.NET 2.0 SP1)<p align=left><font face=Arial size=2>Some time ago I <a title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1843809&amp;SiteID=1" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1843809&amp;SiteID=1">reported about bugs</a> in <strong>System.Net.Mail.MailMessage</strong> (.NET 2.0), hoping for a fix in SP1 of .NET 2.0. Well, unfortunately most of them still exist.</font></p> <ol> <li>With MailMessage.Headers there is a bug where headers will have <strong>white space in an encoded text</strong>. This will lead to non-RFC2047 compliant messages, which will increase the SPAM rating of the message. MailAddresses (also to be considered as headers) are effected as well. <li> <div align=left><strong>Quoted-Printable encoding</strong> is not limited to a maximum of <strong>76 characters</strong> in System.Net.Mail. RFC2045 requires that Quoted-Printable encoding encodes lines be no more than 76 characters long. If longer lines are to be encoded with the Quoted-Printable encoding, &quot;soft&quot; line breaks must be used.</div> <li> <div align=left>MailMessage.To.ToString() returns the encoded string only after the message was sent. According to the documentation this should be the case no matter whether the message was already sent or not.</div></li></ol> <p align=left>As a matter of fact I hacked System.Net.Mail using Reflection, published <a title="http://www.codeproject.com/KB/IP/MailMergeLib.aspx" href="http://www.codeproject.com/KB/IP/MailMergeLib.aspx">here</a> (relevant class: Bugfixer.cs).</p> <p align=left>I consider these bugs very simple to fix, so I'm just wondering what else I could do to make this happen? <img src="http://forums.microsoft.com/MSDN/WebResource.axd?d=NySzF1eivP_rMoc50GQJzcvS4MHMOEKwYrCIgDtzuzlw7GsNki3H_INlfYaLgkxFdA4ESFRtesEUXj11MHjIL5WMBvm3Pubiu_iWcnqAaGQ1&amp;t=633263991144971555"></p>NorbertSun, 13 Jan 2008 13:42:57 Z2009-11-19T21:37:50Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ef987176-62dd-4c3f-ae1e-92e99990375fhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ef987176-62dd-4c3f-ae1e-92e99990375fdyynohttp://social.msdn.microsoft.com/Profile/en-US/?user=dyynoFile Transfer Web ServiceHi,<br/><br/>I was wondering if anyone was able to help me with the problem I am having.<br/><br/>I have created a web application which sends a WebRequest (Server A) to a server which recieves that request (Server B) and then sends a file back to Server A.<br/>The way the application works is like this. Server A sends a request to Server B with certain parameters. Server B recieves the parameters then runs a tiny encryption application and creates a file (~30kb). The file is then sent to Server A using the HTTP Response. The problem I am having is that <br/>i have to send two WebRequests and recieve the file twice inorder for it to be the right file. On the first WebRequest it sends the file that was created by the previous session.<br/>There is also the odd time that the file is recieved is corrupt (~2kb).<br/><br/>Now my question is, are there any other ways which might be better for this type of application (maybe using FTP) or can anyone help me solve the problem so that the right file can be sent the first time?Thu, 19 Nov 2009 21:12:44 Z2009-11-19T21:12:45Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/673817a5-bab9-47bb-adf2-654f9f42738bhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/673817a5-bab9-47bb-adf2-654f9f42738bshortcutshttp://social.msdn.microsoft.com/Profile/en-US/?user=shortcutsIp connection not foundHey,<br/><br/>I made a little client and server so i could chat between 2computers, using ip connection.<br/><br/>It works fine, but i doesn't work with everyone. <br/>I tried to login from different computers, but it only works when i try from my dad's computer and also with one of my friends computer.<br/><br/><br/>So i'm wondering what the problem could be, that other computers can't find my server?<br/>I gues it has something to do with properties but don't know what yet.<br/><br/>thnx..<br/><br/>Thu, 19 Nov 2009 17:48:51 Z2009-11-23T07:53:13Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a8778635-4228-466a-9aaa-006ef181e508http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a8778635-4228-466a-9aaa-006ef181e508Please help with my query.http://social.msdn.microsoft.com/Profile/en-US/?user=Please%20help%20with%20my%20query.Using sockets to return data from a third party applicationAny help with this will  be appreciated.<br/><br/>I have a .NET application that is builds an object that I have serialized and using a (async) socket sent to the server application.<br/><br/>When the server application receives the data, it then issues a request to a third party application, which sends a result back to the server.  <br/><br/>When the server receives this, it serializes the data.  What I can't seem to achieve, is getting the serialized List back to the .NET application, which will be required to process the result.<br/><br/>Thanks, in advance and I apologise if this is in the wrong forum.<br/>Wed, 18 Nov 2009 13:41:47 Z2009-11-19T17:46:36Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/00adb8a7-9c52-47a3-8acc-73ae499ca09fhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/00adb8a7-9c52-47a3-8acc-73ae499ca09fnewCRMsupporthttp://social.msdn.microsoft.com/Profile/en-US/?user=newCRMsupportReading messages from MSMQ COM to MSMQ .NETWe have a company sending MSMQ messages but they are using ASP, VBScript, and COM. Now we are using .NET (3.5), VB.NET, and ASP.NET to read the MSMQ messages. MSMQ fails on our side when we try to read the message. We have the Formatter as ActiveX, but still fails.Thu, 19 Nov 2009 14:58:40 Z2009-11-19T14:58:40Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/701ffe9f-b45a-4715-ac50-e1e4f483f11ahttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/701ffe9f-b45a-4715-ac50-e1e4f483f11avtortolahttp://social.msdn.microsoft.com/Profile/en-US/?user=vtortolaWhat is wrong with this class in WCF?<br/> Hi,<br/> <br/> I'm totally clueless with this problem, I've looked for a lot of possible solutions, but no one works.<br/> <br/> I have a service with several methods, all of them work fine but one, that returns a custom class &quot;PublishedWebDefinition&quot;:<br/> <br/> <pre lang="x-c#"> [Serializable]<br/> [CollectionDataContract]<br/> public class WebMenuEntryCollection : List&lt;WebMenuEntry&gt; {}<br/> <br/> //[DataContract]<br/> //public enum WebPageType {None, Query, Table }<br/> <br/> [DataContract]<br/> public class WebMenuEntry<br/> {<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public WebMenuEntryCollection Childs { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String Name { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String Key { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public WebPublishedPageDefinition Page { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public WebMenuEntry Parent { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Int32 Order { get; set; }<br/> }<br/> <br/> [DataContract]<br/> public class WebPublishedPageDefinition<br/> {<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Int32 PageType { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Int32 DataSourceId { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String Filter { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Boolean CanBeModified { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Boolean IsPkDisplayed { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Boolean IsReadOnly { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Boolean IsCreateOnly { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Boolean IsListOnly { get; set; }<br/> }<br/> <br/> [DataContract]<br/> public class PublishedWebDefinition<br/> {<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public WebMenuEntry MenuTreeRoot { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String WebName { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String LoginTableName { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String LoginColumnName { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String PasswordColumnName { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public String PasswordEmail { get; set; }<br/> [DataMember(IsRequired=false, EmitDefaultValue = false )]<br/> public Boolean LoginFirst { get; set; }<br/> }</pre> I got the following error when I try to call the method:<br/> <br/> System.ServiceModel.CommunicationException occurred<br/>   Message=&quot;An error occurred while receiving the HTTP response to http://pc-vtortola.yepayepa.local/DkWebPublisher2/DkPublisherService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.&quot;<br/>   Source=&quot;mscorlib&quot;<br/>   <br/> <br/> The class is build in the server, and is built ok, but when it has to return it to the client... then the error appears.<br/> <br/> I've also checked the binding configuration:<br/> <br/> <pre lang=x-xml> &lt;system.serviceModel&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&quot;true&quot;/&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name=&quot;LargeSize&quot; maxBufferSize=&quot;2147483647&quot; maxReceivedMessageSize=&quot;2147483647&quot;&gt; &lt;readerQuotas maxDepth=&quot;2147483647&quot; maxStringContentLength=&quot;2147483647&quot; maxArrayLength=&quot;2147483647&quot; maxBytesPerRead=&quot;2147483647&quot; maxNameTableCharCount=&quot;2147483647&quot;/&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name=&quot;GetDataBehavior&quot;&gt; &lt;serviceMetadata httpGetEnabled=&quot;true&quot;/&gt; &lt;serviceDebug includeExceptionDetailInFaults=&quot;false&quot;/&gt; &lt;/behavior&gt; &lt;behavior name=&quot;GenericBehavior&quot;&gt; &lt;serviceMetadata httpGetEnabled=&quot;true&quot;/&gt; &lt;serviceDebug includeExceptionDetailInFaults=&quot;false&quot;/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;services&gt; &lt;service behaviorConfiguration=&quot;GetDataBehavior&quot; name=&quot;DkWebPublisher2.DkPublisherService&quot;&gt; &lt;endpoint address=&quot;&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;LargeSize&quot; contract=&quot;DkWebPublisher2.IDkPublisherService&quot;&gt; &lt;identity&gt; &lt;dns value=&quot;localhost&quot; /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address=&quot;mex&quot; binding=&quot;mexHttpBinding&quot; contract=&quot;IMetadataExchange&quot; /&gt; &lt;/service&gt; &lt;/services&gt; &lt;/system.serviceModel&gt; </pre> I don't know what is the problem :S :S Apparently there is something wrong with the definition of the classes for WCF... but I don't know what!<br/> <br/> Kind regards.<br/><hr class="sig">.: Valeriano Tórtola MCTS WPF :.: http://www.vtortola.net :.Thu, 19 Nov 2009 12:37:12 Z2009-11-19T14:12:39Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/fa97d039-5ab1-4ab0-917d-7b668335e195http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/fa97d039-5ab1-4ab0-917d-7b668335e195Naresh Sharmahttp://social.msdn.microsoft.com/Profile/en-US/?user=Naresh%20SharmaGuidance needed for printer monitoringHi All,<br/><br/>I am on to developing an application in c# for monitoring and controlling printers on the network including things like who is printing how many pages and if needed, to be able to cancel a particular print job.<br/><br/>Appreciate if anyone can point me in the right direction. Is SNMP the only answer... what is the best .NET API to use... where to get the information... good links etc.. anything would be useful.<br/><br/>I have seen many other questions on this forum with them going unanswered... I hope this thread will not land up the same way.<br/><br/>Thanks in advanceThu, 19 Nov 2009 08:27:00 Z2009-11-19T08:27:01Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/2360f970-4085-4fe3-b224-a22bedefba6bhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/2360f970-4085-4fe3-b224-a22bedefba6bRMDhttp://social.msdn.microsoft.com/Profile/en-US/?user=RMDP2P "Lost" MessagesI have a simple P2P application that essentially allows users to chat via the command line. (This is a proof of concept app.)<br/><br/>When each console is started, it creates a new self hosted instance of the &quot;P2PService&quot;. It then creates a nother instance of the P2PService, establishes a duplex channel, and finally calls the &quot;JoinMesh&quot; method, which should print out on everybody's screen &quot;MachineName has joined the mesh.&quot; It allows the user to enter text which is then sent via the &quot;SendMessage&quot; method to all members of the mesh. Finally, when the console is closed, the &quot;LeaveMesh&quot; method annouces to the mesh that the machine has left.<br/><br/>The SendMessage and LeaveMesh calls seem to work perfectly, but the JoinMesh call happens on the peers. I've tried also adding an &quot;InitMesh&quot; call, which does nothing but just tries to &quot;prime&quot; the mesh so that subsequent calls will work... and that has no effect.<br/><br/>Ideas?Wed, 18 Nov 2009 22:27:49 Z2009-11-18T22:27:50Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/70bcd58a-86a4-4a42-ba9b-244429945450http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/70bcd58a-86a4-4a42-ba9b-244429945450Thiagossrshttp://social.msdn.microsoft.com/Profile/en-US/?user=ThiagossrsUDP Receive Packet.Let's say i have this code to receive UDP Packets:<br/> <br/> <h1><code><span style="color:#ffffff"> </span> <span style="color:#7f0055"><strong>Dim </strong> </span> <span style="color:#000000">data </span> <span style="color:#7f0055"><strong>As </strong> </span> <span style="color:#000000">Byte</span> <span style="color:#000000">() </span> <span style="color:#000000">= client.Receive</span> <span style="color:#000000">(</span> <span style="color:#000000">receivePoint</span> <span style="color:#000000">)</span> </code></h1> Let's say the sender send two or more packets exactly one after the other.<br/> <br/> And let's say i take a few milliseconds to perform the code line above.<br/> <br/> My question:<br/> <br/> Will the packets be merged? when i read the executed line all my packets data will be on the data variable?<br/> <br/> Or let's say if i send 3 packets, I'll have to execute the line 3 times to get all the packets?<br/> <br/> If the answer is that the packets are merged. Is it possible to make then not be merged?<br/> <br/> Thanks<br/> <br/> Thiago<br/>Wed, 18 Nov 2009 18:44:47 Z2009-11-18T18:44:48Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/25981a6e-13a1-423c-a08d-5bdb93d97b55http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/25981a6e-13a1-423c-a08d-5bdb93d97b55pepormhttp://social.msdn.microsoft.com/Profile/en-US/?user=pepormClient Certificates - WebServiceHello<br/><br/>I have WebService which requires client certificates. Client Certificates are on Smart Cards, which are connected to the computer with usb. When I use Internet Explorer to browse to this secure web site, then I am being prompted to choose my client certificate - i am going to choose the proper one, i am being prompted for pin code (with crypto api provided by smart card vendor) and everything works fine, ssl connection is established - i am able to work with this web service. I would like to do something similar in forms client. I am using Request.ClientCredentials.Certificate property without succes - I am choosing right certificate, i am not being prompted for pin and trusted ssl connection cannot be established. Has anybody got any experiences with this topic ? Prepare secure connection in client forms application to client certificate required secure web service, cache it and use as normal web service to the client. I am trying to do it with cspparams without success. Also have tried some functions from System.Net and System.Net.Security without success. Could you share with your experience ? Thanks in advanceTue, 17 Nov 2009 09:33:39 Z2009-11-18T18:01:31Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/b07d6ce3-2f9f-454c-8986-e44c5d1c2576http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/b07d6ce3-2f9f-454c-8986-e44c5d1c2576Euyeusuhttp://social.msdn.microsoft.com/Profile/en-US/?user=EuyeusuProblem to read Web pages wich contain 0x00 characters. Response content is truncated<p>Hello,</p> <p>I write a program wich download web pages. It works fine for most of web pages but i have found some pages where it doesn't work.</p> <p>These pages contains 0x00 characters.</p> <p>I'm able to read page content until this character, but not the content after. The response stream consider the 0x00 byte as the end of the stream.</p> <p>I use this part of code to read the response :</p> <pre class=prettyprint><code><span class=typ><span style="color:#2b91af">IAsyncResult</span></span><span class=pln> ar </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">null</span></span><span class=pun>;</span><span class=pln>  </span><span class=typ><span style="color:#2b91af">HttpWebResponse</span></span><span class=pln> resp </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">null</span></span><span class=pun>;</span><span class=pln>  </span><span class=typ><span style="color:#2b91af">Stream</span></span><span class=pln> responseStream </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">null</span></span><span class=pun>;</span><span class=pln>  </span><span class=typ><span style="color:#2b91af">String</span></span><span class=pln> content </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">null</span></span><span class=pun>;</span><span class=pln>  </span><span class=pun>...</span><span class=pln>  resp </span><span class=pun>=</span><span class=pln> </span><span class=pun>(</span><span class=typ><span style="color:#2b91af">HttpWebResponse</span></span><span class=pun>)</span><span class=pln>req</span><span class=pun>.</span><span class=typ><span style="color:#2b91af">EndGetResponse</span></span><span class=pun>(</span><span class=pln>ar</span><span class=pun>);</span><span class=pln>  responseStream </span><span class=pun>=</span><span class=pln> resp</span><span class=pun>.</span><span class=typ><span style="color:#2b91af">GetResponseStream</span></span><span class=pun>();</span><span class=pln>  </span><span class=typ><span style="color:#2b91af">StreamReader</span></span><span class=pln> sr </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">new</span></span><span class=pln> </span><span class=typ><span style="color:#2b91af">StreamReader</span></span><span class=pun>(</span><span class=pln>responseStream</span><span class=pun>,</span><span class=pln> </span><span class=typ><span style="color:#2b91af">Encoding</span></span><span class=pun>.</span><span class=pln>UTF8</span><span class=pun>);</span><span class=pln>  content </span><span class=pun>=</span><span class=pln> sr</span><span class=pun>.</span><span class=typ><span style="color:#2b91af">ReadToEnd</span></span><span class=pun>();</span><span class=pln>  </span></code></pre> <p>In this example i use asynchronous request, but i try with synchronous one and i have the same probleme.</p> <p>I also try this with the same result :</p> <pre class=prettyprint><code><span class=typ><span style="color:#2b91af">HttpWebResponse</span></span><span class=pln> resp </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">null</span></span><span class=pun>;</span><span class=pln>  </span><span class=typ><span style="color:#2b91af">Stream</span></span><span class=pln> responseStream </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">null</span></span><span class=pun>;</span><span class=pln>  </span><span class=typ><span style="color:#2b91af">String</span></span><span class=pln> content </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">new</span></span><span class=pln> </span><span class=typ><span style="color:#2b91af">String</span></span><span class=pun>();</span><span class=pln>  </span><span class=pun>...</span><span class=pln>  responseStream </span><span class=pun>=</span><span class=pln> resp</span><span class=pun>.</span><span class=typ><span style="color:#2b91af">GetResponseStream</span></span><span class=pun>();</span><span class=pln>  </span><span class=kwd><span style="color:#00008b">byte</span></span><span class=pun>[]</span><span class=pln> buffer </span><span class=pun>=</span><span class=pln> </span><span class=kwd><span style="color:#00008b">new</span></span><span class=pln> </span><span class=kwd><span style="color:#00008b">byte</span></span><span class=pun>[</span><span class=lit><span style="color:#800000">4096</span></span><span class=pun>];</span><span class=pln>  </span><span class=kwd><span style="color:#00008b">int</span></span><span class=pln> bytesRead </span><span class=pun>=</span><span class=pln> </span><span class=lit><span style="color:#800000">1</span></span><span class=pun>;</span><span class=pln>  </span><span class=kwd><span style="color:#00008b">while</span></span><span class=pln> </span><span class=pun>(</span><span class=pln>bytesRead </span><span class=pun>&gt;</span><span class=pln> </span><span class=lit><span style="color:#800000">0</span></span><span class=pun>)</span><span class=pln>  </span><span class=pun>{</span><span class=pln>      bytesRead </span><span class=pun>=</span><span class=pln> responseStream</span><span class=pun>.</span><span class=typ><span style="color:#2b91af">Read</span></span><span class=pun>(</span><span class=pln>buffer</span><span class=pun>,</span><span class=pln> </span><span class=lit><span style="color:#800000">0</span></span><span class=pun>,</span><span class=pln> </span><span class=lit><span style="color:#800000">4096</span></span><span class=pun>);</span><span class=pln>      content </span><span class=pun>+=</span><span class=pln> </span><span class=typ><span style="color:#2b91af">Encoding</span></span><span class=pun>.</span><span class=pln>UTF8</span><span class=pun>.</span><span class=typ><span style="color:#2b91af">GetString</span></span><span class=pun>(</span><span class=pln>buffer</span><span class=pun>,</span><span class=pln> </span><span class=lit><span style="color:#800000">0</span></span><span class=pun>,</span><span class=pln> bytesRead</span><span class=pun>);</span><span class=pln>  </span><span class=pun>}</span><span class=pln>  </span></code></pre> <p>for example, the problem occurs for this url <a rel=nofollow href="http://www.daz3d.com/i/search/searchsub?sstring=ps_tx1662b&amp;_m=dps_tx1662b"><span style="color:#0077cc">http://www.daz3d.com/i/search/searchsub?sstring=ps%5Ftx1662b&amp;%5Fm=dps%5Ftx1662b</span></a></p> <p>thanks for yours responses</p> <p>Euyeusu<br/><br/>PS : The problem is the same with class WebClient</p>Tue, 17 Nov 2009 13:43:19 Z2009-11-18T15:25:05Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/d16751dc-bca8-42e7-b4d8-aa33d3c58947http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/d16751dc-bca8-42e7-b4d8-aa33d3c58947LMMhttp://social.msdn.microsoft.com/Profile/en-US/?user=LMMunwanted TCP connections to unknown IPs when converting XLS to SDF<br/> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>I have a problem that I cannot fix. For one of our clients we have prepared a simple application written in .NET environment, which task is to gather inventory data. The entire application includes stationary(server) and mobile part. Application functionality is shortly as follows: after inventory, when we choose a “synchro” option at the mobile device, server (which is equipped with TCP listener) receives data (sdf file) and converts those data into the Excel file. In another step dictionary data from Excel file are converted into a sdf file and send back to mobile device (further action is not significant). And there comes a problem – when the mobile device is trying to import data from server. When a computer on which the server application is running is connected to LAN network – instead of sending the file – tries to connect to “unknown” hosts. When the server application starts with card network switched off then the problem doesn’t occur and the file is correctly sent between the mobile device and the server. Customer’s network has security policy that make such connection to outside hosts impossible - our application cannot connect to chosen &quot;unknown&quot; host thus making any further actions<span>  </span> impossible. </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>Below is a list of hosts to which our application is trying to connect:</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>a) 165.254.53.91                                                                              //NTT America</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>b) 65.124.174.51                                                                             //Qwest Communications Company</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>c) 165.254.53.145                                                                            //NTT America</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>d) 72.215.224.50                                                                             //??</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>e) 65.124.174.33                                                                             //Qwest Communications Company</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>g) 205-177-69-32.static.pccwglobal.net                                 //PCCWGlobal</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>i) a96-17-151-89.deploy.akamaitechnologies.com           //Akamai Technologies</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>j) 156.24.2.98                                                                                   //??</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>Companies at which are pointing above IP addresses have very similar activity profile. </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US> </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US> </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>On the PC computer with application are installed:</span></p> <p class=MsoListParagraph style="text-indent:-18pt"><span style="font-size:12pt;color:#1f497d" lang=EN-US><span>a)<span style="font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal">      </span> </span> </span> <span style="font-size:12pt;color:#1f497d" lang=EN-US>Windows XP SP2 English</span></p> <p class=MsoListParagraph style="text-indent:-18pt"><span style="font-size:12pt;color:#1f497d" lang=EN-US><span>b)<span style="font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal">      </span> </span> </span> <span style="font-size:12pt;color:#1f497d" lang=EN-US>Microsoft .NET Framework 2.0 Service Pack 1 (x86)</span></p> <p class=MsoListParagraph style="text-indent:-18pt"><span style="font-size:12pt;color:#1f497d" lang=EN-US><span>c)<span style="font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal">      </span> </span> </span> <span style="font-size:12pt;color:#1f497d" lang=EN-US>Microsoft ActiveSync 4.2 </span></p> <p class=MsoListParagraph style="text-indent:-18pt"><span style="font-size:12pt;color:#1f497d" lang=EN-US><span>d)<span style="font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal">      </span> </span> </span> <span style="font-size:12pt;color:#1f497d" lang=EN-US>MS Office 2007 Pro Plus 2007 English</span></p> <p class=MsoListParagraph style="text-indent:-18pt"><span style="font-size:12pt;color:#1f497d" lang=EN-US><span>e)<span style="font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal">      </span> </span> </span> <span style="font-size:12pt;color:#1f497d" lang=EN-US>Windows Installer 3.1</span></p> <p class=MsoListParagraph style="text-indent:-18pt"><span style="font-size:12pt;color:#1f497d" lang=EN-US><span>f)<span style="font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal">       </span> </span> </span> <span style="font-size:12pt;color:#1f497d" lang=EN-US>SQL 2005 libraries which are needed by our application.</span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US> </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>We conducted a test also on other computers and it turned out that the application connected with the chosen host only once. After such successful connection the described problem is no longer appearing for particular computer. </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>After series of tests we think that we narrowed the circle of sources of this problem a little bit. We think that the problem is occurring in the moment of the conversion of the XLS (Excel) file to SDF file. The source can be ActiveX libraries for integration with the Excel (Office.dll, Microsoft.Office.Interop.Excel.dll, Microsoft.Vbe.Interop.dll), or libraries for integration with SQL CE (System.Data.SqlServerCe.dll). We suspect this first option but we are not sure. </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US> </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>Because security policy doesn't let any software to make connections with unknown outside addresses our software cannot work and that becomes a problem. </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US> </span></p> <p class=MsoNormal><span style="font-size:12pt;color:#1f497d" lang=EN-US>Could you give me any hint how to solve the problem?</span></p> <p class=MsoNormal> </p> <p class=MsoNormal>regards</p> <p class=MsoNormal>LMM</p> <hr class=sig> best regardsWed, 18 Nov 2009 13:03:38 Z2009-11-18T13:03:39Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/591f3b99-4071-4311-bf2d-bb10a47753c3http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/591f3b99-4071-4311-bf2d-bb10a47753c3Jiten Patoliyahttp://social.msdn.microsoft.com/Profile/en-US/?user=Jiten%20PatoliyaUDP Socket connection specifying local Lan IP from 2 LancardsI am having Two Lancards installed on my computer<br/><br/>Lan1: 192.168.0.152<br/>Lan2: 192.168.111.252<br/><br/>Bcast details<br/>Remote Address: 235.1.2.96<br/>Remote Port : 6789<br/><br/>This is the broadcast details on Lancard IP: 192.168.111.252<br/><br/><br/>How can i make UDP connection and getbroadcast from the give remote details and specifying 192.168.111.252 at the same time.<br/><br/> <hr class=sig> Thanks for the help!Mon, 16 Nov 2009 11:07:41 Z2009-11-19T08:54:36Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/3339a397-221d-4108-84a2-f506bd7a13cehttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/3339a397-221d-4108-84a2-f506bd7a13ceKartheechidambaramhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kartheechidambaramclass for sftp in .net 2.0Is there any class available for SFTP in .net framework 2.0? If there is any provision availble in other frameworks <br/>kindly mention in the answer?<br/><br/>how to write a SFTP client ,SFTP server in .net 2.0?is there any option to write it in vc++?Wed, 18 Nov 2009 04:23:18 Z2009-11-18T04:23:19Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/c93d1f0a-53ad-4da4-9730-3bf56547e359http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/c93d1f0a-53ad-4da4-9730-3bf56547e359SCEFhttp://social.msdn.microsoft.com/Profile/en-US/?user=SCEFServer 2003 and Share AddressingI have two Windows 2003 servers. One server has a long/cryptic name, so I created a LMHOSTS file with a short named entry on the second server. I cannot access the share. Why?<br/> <br/> If I do &quot;dir \\svrnyc88302app\open&quot; I get a file listing.<br/> If I do &quot;dir \\shortname\open&quot; I get &quot;Windows cannot find the network path....&quot; <br/> If I do &quot;ping shortname&quot; I get the IP number I specified in LMHOSTS<br/> <br/> LMHOSTS has only this line:<br/> <br/> 10.3.0.4   shortname #MH<br/> <br/> Help?<br/>Tue, 17 Nov 2009 21:55:28 Z2009-11-17T21:55:29Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/e554ebc5-7b74-415f-8ac8-d5dc3dcaf1c5http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/e554ebc5-7b74-415f-8ac8-d5dc3dcaf1c5Dreicohttp://social.msdn.microsoft.com/Profile/en-US/?user=DreicoLooking for Granados SSH Example???<p align=left><font face=Arial size=2></font> </p> <p>As a Unix sysadmin it's common the need of executeing the same commands on several unix servers, since I'm not a professional programmer I decided to develop my own solution and learn about C# in the way. So this small project started.  Unfortunatelly I found out that there are no opensource SSH API's for .NET (only SharpSSH and Granados), the first one comes along with documentation and examples but I couldn't get it to work correctly, so I tried the second one but there were no examples avalilable!!! <img src="http://forums.microsoft.com/MSDN/WebResource.axd?d=NySzF1eivP_rMoc50GQJzcvS4MHMOEKwYrCIgDtzuzlw7GsNki3H_INlfYaLgkxFpO8EaQy1EzJi-hKmVgQkI0DPXpVlZ_LknXuTgTE5vEE1&amp;t=633229584498879646">   (If you are reading this is probably for the same reason.. hehe)</p> <p align=left> </p> <p align=left>So, I took a dive into a projet called TerminalControl (<a title="http://www.codeproject.com/cs/internet/terminalcontrol.asp" href="http://www.codeproject.com/cs/internet/terminalcontrol.asp">http://www.codeproject.com/cs/internet/terminalcontrol.asp</a>) and finally made my project work</p> <p align=left> </p> <p align=left>Basically what my project does is the following: </p> <ol> <li> <div align=left>Get a list of commands to exectue</div> <li> <div align=left>Get the list of server where the commands should be executed</div> <li> <div align=left>Open a SSH connection to each listed server</div> <li> <div align=left>Execute on command at a time</div> <li> <div align=left>Retrieve the command output and show it to the user</div> <li> <div align=left>Optionally you can send the whole output to a .csv file for further analysis</div></li></ol> <p align=left></p> <p> </p> <p align=left>The main code pieces (SSH connection and data send/receive)</p> <p align=left> </p> <p align=left><font size=2></font><font color="#0000ff" size=2> </p> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%"> <p>SSH Object</p> <p align=left> </p></span></div> <p align=left><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#008080" size=2>Reader</font><font size=2> : Routrek.SSHC.</font><font color="#008080" size=2>ISSHConnectionEventReceiver</font><font size=2>, Routrek.SSHC.</font><font color="#008080" size=2>ISSHChannelEventReceiver</p></font><font size=2> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>event</font><font size=2> </font><font color="#008080" size=2>RcvdData</font><font size=2> notify;</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> Routrek.SSHC.</font><font color="#008080" size=2>SSHConnection</font><font size=2> _conn;</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>bool</font><font size=2> _ready;</p> <p align=left></font><font color="#0000ff" size=2>private</font><font size=2> </font><font color="#008080" size=2>String</font><font size=2> rcvdText;</p> <p align=left></font><font color="#008000" size=2>//This is the function called every time we receive data through the connection</font></p> <p align=left><font color="#008000">//so we notify the main app that we received and event and pass the received string</font></p> <p align=left><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnData(</font><font color="#0000ff" size=2>byte</font><font size=2>[] data, </font><font color="#0000ff" size=2>int</font><font size=2> offset, </font><font color="#0000ff" size=2>int</font><font size=2> length)</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>rcvdText = System.Text.</font><font color="#008080" size=2>Encoding</font><font size=2>.ASCII.GetString(data, offset, length);</font></p> <p align=left><font size=2>notify(</font><font color="#0000ff" size=2>this</font><font size=2>, rcvdText);</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnDebugMessage(</font><font color="#0000ff" size=2>bool</font><font size=2> always_display, </font><font color="#0000ff" size=2>byte</font><font size=2>[] data)</p> <p align=left>{</p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnIgnoreMessage(</font><font color="#0000ff" size=2>byte</font><font size=2>[] data)</p> <p align=left>{</p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnAuthenticationPrompt(</font><font color="#0000ff" size=2>string</font><font size=2>[] msg)</p> <p align=left>{</p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnError(</font><font color="#008080" size=2>Exception</font><font size=2> error, </font><font color="#0000ff" size=2>string</font><font size=2> msg)</p> <p align=left>{</p> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnChannelClosed()</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left>_conn.Disconnect(</font><font color="#800000" size=2>&quot;&quot;</font><font size=2>);</p></blockquote></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnChannelEOF()</p> <p align=left>{</p> <p align=left>_pf.Close();</p> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnExtendedData(</font><font color="#0000ff" size=2>int</font><font size=2> type, </font><font color="#0000ff" size=2>byte</font><font size=2>[] data)</p> <p align=left>{</p> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnConnectionClosed()</p> <p align=left>{</p> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnUnknownMessage(</font><font color="#0000ff" size=2>byte</font><font size=2> type, </font><font color="#0000ff" size=2>byte</font><font size=2>[] data)</p> <p align=left>{</p> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnChannelReady()</p> <p align=left>{</p> <p align=left>_ready = </font><font color="#0000ff" size=2>true</font><font size=2>;</p> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnChannelError(</font><font color="#008080" size=2>Exception</font><font size=2> error, </font><font color="#0000ff" size=2>string</font><font size=2> msg)</p> <p align=left>{</p> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> OnMiscPacket(</font><font color="#0000ff" size=2>byte</font><font size=2> type, </font><font color="#0000ff" size=2>byte</font><font size=2>[] data, </font><font color="#0000ff" size=2>int</font><font size=2> offset, </font><font color="#0000ff" size=2>int</font><font size=2> length)</p> <p align=left>{</p> <p align=left>}</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> Routrek.SSHC.</font><font color="#008080" size=2>PortForwardingCheckResult</font><font size=2> CheckPortForwardingRequest(</font><font color="#0000ff" size=2>string</font><font size=2> host, </font><font color="#0000ff" size=2>int</font><font size=2> port, </font><font color="#0000ff" size=2>string</font><font size=2> originator_host, </font><font color="#0000ff" size=2>int</font><font size=2> originator_port)</p> <p align=left>{</p> <p align=left>Routrek.SSHC.</font><font color="#008080" size=2>PortForwardingCheckResult</font><font size=2> r = </font><font color="#0000ff" size=2>new</font><font size=2> Routrek.SSHC.</font><font color="#008080" size=2>PortForwardingCheckResult</font><font size=2>();</p> <p align=left>r.allowed = </font><font color="#0000ff" size=2>true</font><font size=2>;</p> <p align=left>r.channel = </font><font color="#0000ff" size=2>this</font><font size=2>;</p> <p align=left></font><font color="#0000ff" size=2>return</font><font size=2> r;</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> EstablishPortforwarding(Routrek.SSHC.</font><font color="#008080" size=2>ISSHChannelEventReceiver</font><font size=2> rec, Routrek.SSHC.</font><font color="#008080" size=2>SSHChannel</font><font size=2> channel)</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>_pf = channel;</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> Routrek.SSHC.</font><font color="#008080" size=2>SSHChannel</font><font size=2> _pf;</p></blockquote> <p align=left>}</p></font> <p align=left> </p></div></div> <p align=left> </p></font> <p></p><font size=2> <p align=left></p></font> <p align=left> </p> <p align=left> </p> <p align=left> </p><font size=2> <p align=left></font><font color="#0000ff" size=2> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Method to open the SSH connection</span></div> <p align=left><font color="#0000ff" size=2>private</font><font size=2> </font><font color="#0000ff" size=2>bool</font><font size=2> connect(</font><font color="#0000ff" size=2>string</font><font size=2> hostname, </font><font color="#0000ff" size=2>string</font><font size=2> user, </font><font color="#0000ff" size=2>string</font><font size=2> pass)</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>f.UserName = user;</p> <p align=left>f.Password = pass; </p> <p align=left>f.Protocol = Routrek.SSHC.</font><font color="#008080" size=2>SSHProtocol</font><font size=2>.SSH2;</p> <p align=left>f.AuthenticationType = Routrek.SSHC.</font><font color="#008080" size=2>AuthenticationType</font><font size=2>.Password;</p> <p align=left>f.WindowSize = 0x1000;</p> <p align=left>reader = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>Reader</font><font size=2>();</p> <p align=left></font><font color="#008080" size=2>Socket</font><font size=2> s = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>Socket</font><font size=2>(</font><font color="#008080" size=2>AddressFamily</font><font size=2>.InterNetwork, </font><font color="#008080" size=2>SocketType</font><font size=2>.Stream, </font><font color="#008080" size=2>ProtocolType</font><font size=2>.Tcp);</p> <p align=left></font><font color="#008080" size=2>IPAddress</font><font size=2> ip;</p> <p align=left></font><font color="#0000ff" size=2>try</p></font><font size=2> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>ip = </font><font color="#008080" size=2>Dns</font><font size=2>.GetHostByName(hostname).AddressList[0];</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>catch</p></font><font size=2> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>this</font><font size=2>.sshOutput.AppendText(</font><font color="#800000" size=2>&quot;Couldn't resolve HostName&quot;</font><font size=2> + System.</font><font color="#008080" size=2>Environment</font><font size=2>.NewLine);</p> <p align=left>s.Close();</p> <p align=left></font><font color="#0000ff" size=2>return</font><font size=2> </font><font color="#0000ff" size=2>false</font><font size=2>;</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>try</p></font><font size=2> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>s.Connect(</font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>IPEndPoint</font><font size=2>(ip, 22));</p></blockquote> <p align=left>}</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>catch</font><font size=2> (</font><font color="#008080" size=2>Exception</font><font size=2> e)</p></blockquote> <p align=left>{</p> <p align=left></font><font color="#0000ff" size=2>this</font><font size=2>.sshOutput.AppendText(System.</font><font color="#008080" size=2>Environment</font><font size=2>.NewLine + e.Message + System.</font><font color="#008080" size=2>Environment</font><font size=2>.NewLine);</p> <p align=left></font><font color="#0000ff" size=2>return</font><font size=2> </font><font color="#0000ff" size=2>false</font><font size=2>;</p> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>try</p></font><font size=2> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#008000" size=2>//Open the connection</p></font><font size=2> <p align=left>_conn = Routrek.SSHC.</font><font color="#008080" size=2>SSHConnection</font><font size=2>.Connect(f, reader, s);</p> <p align=left>reader._conn = _conn;</p> <p align=left></font><font color="#008000" size=2>//Open the channel to transmit data</p></font><font size=2> <p align=left>Routrek.SSHC.</font><font color="#008080" size=2>SSHChannel</font><font size=2> ch = _conn.OpenShell(reader);</p> <p align=left>reader._pf = ch;</p> <p align=left></font><font color="#008000" size=2>//get connection information</p></font><font size=2> <p align=left>Routrek.SSHC.</font><font color="#008080" size=2>SSHConnectionInfo</font><font size=2> ci = _conn.ConnectionInfo;</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>catch</font><font size=2> (</font><font color="#008080" size=2>Exception</font><font size=2> e)</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>this</font><font size=2>.sshOutput.AppendText(</font><font color="#800000" size=2>&quot;Error!!! &quot;</font><font size=2> + e.Message + System.</font><font color="#008080" size=2>Environment</font><font size=2>.NewLine);</p> <p align=left></font><font color="#0000ff" size=2>return</font><font size=2> </font><font color="#0000ff" size=2>false</font><font size=2>;</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#008000" size=2>//Add the event handler that will trigger the function to update sshOutput every time data is received</p></font><font size=2> <p align=left></font><font color="#008000" size=2>//on the SSH connection</p></font><font size=2> <p align=left>reader.notify += </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>RcvdData</font><font size=2>(printResult);</p> <p align=left></font><font color="#0000ff" size=2>return</font><font size=2> </font><font color="#0000ff" size=2>true</font><font size=2>;</p></blockquote> <p align=left>}</p></font> <p align=left> </p></div></div> <p align=left> </p></font> <p></p><font size=2> <p align=left></p><font size=2> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">To transmit data</span></div><font size=2> <p align=left>reader._pf.Transmit(</font><font color="#008080" size=2>Encoding</font><font size=2>.ASCII.GetBytes(nextCommand), 0, nextCommand.Length);</font></p> <p align=left> </p></div></div> <p align=left> </p></font><font size=2> <p></p><font size=2> <p align=left></font><font color="#0000ff" size=2> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Print received data</span></div><font size=2> <p align=left><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> printResult(</font><font color="#0000ff" size=2>object</font><font size=2> sender, </font><font color="#0000ff" size=2>string</font><font size=2> s)</p> <p align=left>{</p> <p align=left></font><font color="#0000ff" size=2>if</font><font size=2> (sshOutput.InvokeRequired)</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#008080" size=2>RcvdData</font><font size=2> d = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>RcvdData</font><font size=2>(printResult);</p> <p align=left>sshOutput.Invoke(d, </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#0000ff" size=2>object</font><font size=2>[] { sender, s });</p></blockquote> <p align=left>}</p> <p align=left></font><font color="#0000ff" size=2>else</p></font><font size=2> <p align=left>{</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p align=left>sshOutput.AppendText(s);</p></blockquote></font><font size=2> <p align=left>}</p></font></font> <p align=left> </p></div></div> <p align=left> </p></font> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Other necessary code</span></div><font size=2> <p align=left><font color="#008000" size=2>//delegate to handle SSH connection events</p></font><font size=2> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>delegate</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> </font><font color="#008080" size=2>RcvdData</font><font size=2>(</font><font color="#0000ff" size=2>object</font><font size=2> sender, </font><font color="#008080" size=2>String</font><font size=2> s);</font></p> <p align=left><font size=2></font> </p> <p align=left><font color="#008000">//This lines go into the main class</font></p><font size=2><font size=2> <p align=left></font><font color="#008080" size=2>Reader</font><font size=2> reader; </font><font color="#008000" size=2>//object to send &amp; receive data from SSH connection</p></font><font size=2> <p align=left>Routrek.SSHC.</font><font color="#008080" size=2>SSHConnection</font><font size=2> _conn; </font><font color="#008000" size=2>//SSH Connection</p></font><font size=2> <p align=left>Routrek.SSHC.</font><font color="#008080" size=2>SSHConnectionParameter</font><font size=2> f = </font><font color="#0000ff" size=2>new</font><font size=2> Routrek.SSHC.</font><font color="#008080" size=2>SSHConnectionParameter</font><font size=2>(); </font><font color="#008000" size=2>//Connection parameters</font></p></font></font> <p align=left> </p></div></div> <p align=left> </p> <p></p><font size=2><font size=2> <p align=left><font color="#008000" size=2></p> <p><font color="#000000">I hope this code helps, if u need extra help I could send my entire project</font></p> <p align=left><font color="#000000"></font> </p> <p align=left><font color="#000000">Regards,</font></p> <p align=left> </p> <p align=left><font color="#ff0000" size=3><strong>Note:</strong></font></p> <p align=left><font color="#ff0000" size=3><strong>Lots of people have sent me mails telling that they can't issue any command, most probable causes are:</strong></font></p> <p align=left><font color="#ff0000" size=3><strong>1) You have to wait for the prompt ($,# or %) before issuing a command</strong></font></p> <p align=left><font color="#ff0000" size=3><strong>2) You have to add an &quot;enter&quot; character at the end of each command</strong></font></p> <p align=left> </p></font></font></font></font></font>Fri, 14 Sep 2007 17:30:40 Z2009-11-17T15:09:58Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/08ea9a46-f135-4000-8d1b-a34c64fa6310http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/08ea9a46-f135-4000-8d1b-a34c64fa6310Stewart_Bashhttp://social.msdn.microsoft.com/Profile/en-US/?user=Stewart_BashRemote Registry Call and Open Socket`<p align=left><font face=Arial size=2></font> </p> <p>I recently put together a utility to facilitate some changes on a local network... Long story short, I have to remotely edit the registry of selected workstations, then run a third party EXE (locally) passing in a workstation name as a parameter to complete my process. </p> <p align=left> </p> <p align=left>From the perspective of the application each component works flawlessly... independantly... The remote registry HACK using RegistryKey and OpenRemoteBaseKey and works as expected and documented. I then wrote a process handler for the EXE... This simply creates a local process using ProcessStartInfo and I redirect the output to a StreamWriter to capture what the third party EXE spits out &quot;if executed at a command prompt&quot;. Again, this piece works as expected. The problem that I have is somewhat simple... When I combine these two functions in my application I receive an error from the EXE that tells me &quot;Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again..&quot;</p> <p align=left> </p> <p align=left>I understand what the problem is... RegistryKey and OpenRemoteBaseKey create a socket between the client (my app) and the server (the remote machine). It is then held open for some timeout period even after I diligently Close() and Dispose() of the Registry components in the application. Then as I kick off my executable it bails out with an error telling me that you are trying to connect to the same resouce twice... Here is the question then... How do I either Kill the connection before the EXE, or WAIT until that connection is closed... Is there a timeout period that I can set on the registry connection? </p> <p align=left> </p> <p align=left>Any assistance would be appreciated.</p>Fri, 28 Mar 2008 19:45:25 Z2009-11-17T14:28:49Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/1e0915ab-a968-42ec-a889-712c3cf622e3http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/1e0915ab-a968-42ec-a889-712c3cf622e3vidjai85http://social.msdn.microsoft.com/Profile/en-US/?user=vidjai85Can not bind on a socket that is already being used !!!!!!!!!!Can not bind on a port that is already being used !!!!!!!!!!<br/> <br/> I'm frustrated with this thing..<br/> plzzzzz help..<br/> <br/> <br/> i'm building a porttester, and it is able to bind when a port is closed.<br/> BUT when it is open bij some other service,  it just can NOT bind.<br/> BUT I HAVE TO SEND AND RECEIVE data on that socket !!!<br/> <br/> I can not bind on it<br/> <br/> i get this error  : &quot;Only one usage of each socket address (protocol/network address/port) is normally permitted&quot;<br/> <br/> How can i send and receive data, eventhough the socket is used by some other service???????????????<br/> <br/> <br/> help plzzzzzzzzzzzzzzz???<br/> <br/> i'm just, a beginner in C# so plzzzzzzzzzzzz<br/> <br/> <br/>Tue, 17 Nov 2009 12:06:23 Z2009-11-17T13:21:55Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/01724c7a-ac96-4704-80cc-ff2536f230a4http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/01724c7a-ac96-4704-80cc-ff2536f230a4tsubusahttp://social.msdn.microsoft.com/Profile/en-US/?user=tsubusaCall dll remotelyHi, All<br/><br/>I want to implement a remote calling between two servers in the application, and this refers to two dlls. A 32bit &quot;SQL.dll&quot; exists in the SQL Server which has Windows Server 2003 32bit OS, and another 64bit dll &quot;Exch.dll&quot; is installed in the assembly of IIS server which has Windows Server 2008 64bit OS. Now, I need to call the methods of &quot;Exch.dll&quot; from the &quot;SQL.dll&quot;, are there any ways to implement this?<br/><br/>Any idea please feel free to let me know.<br/><br/><br/>Thanks<br/>Best Regards<br/>tsubusaTue, 17 Nov 2009 10:53:12 Z2009-11-17T10:53:13Z