469,271 Members | 1,719 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

MSXML2.XMLHTTP vb and c#

1
Hi developers,

currently i'm doing a school project and i am stuck on MSXML2.XMLHTTP conversion from vb code to c#.

Below is the vb Coding that i need to convert to C#

Expand|Select|Wrap|Line Numbers
  1.  Dim sUrl As String
  2.  
  3.         Dim xHttp As MSXML2.XMLHTTP
  4.  
  5.  
  6.  
  7.         sUrl = "http://" & sIPAddr & "/forms/push"
  8.  
  9.  
  10.  
  11.         xHttp = New MSXML2.XMLHTTP
  12.  
  13.         xHttp.open("POST", sUrl, True)
  14.  
  15.         xHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  16.  
  17.         xHttp.setRequestHeader("Content-length", sValue.Length)
  18.  
  19.         xHttp.send(sValue)
  20.  
  21. I manage to understand it but i could not find any MSXML2.XMLHTTP to create in C#.
  22.  
  23. i try using this http post but it could not work or return the result i expected.
  24.  
  25. Below is the C# code i programmed
  26.  
  27. System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
  28.  
  29.                 req.ContentType = "application/x-www-form-urlencoded";
  30.                 req.Method = "POST";
  31.  
  32.                 req.ContentLength = PostData.Length;
  33.  
  34.                 System.IO.Stream os = req.GetRequestStream();
  35.                 os.Write(bytes, 0, bytes.Length);
  36.  
  37.                 req.InitializeLifetimeService();
  38.  
  39.                 return os.CanRead.ToString();
Any help will be greatly appreciate.
Thank you
May 9 '07 #1
2 10656
kuser
2
Just checking - did you get the solution to this yet? I need to do the same type of thing.

The following statement generates an error in C# but NOT in VB. Same machine same project.
XMLHTTP40 mxml = new XMLHTTP40();

Error:
Retrieving the COM class factory for component with CLSID {88D969C5-F192-11D4-A65F-0040963251E5} failed due to the following error: 80040154.
Jun 14 '10 #2
Remove 40
XMLHTTP mxml = new XMLHTTP();
Oct 9 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Dmitry | last post: by
3 posts views Thread by Tanmay Saxena via .NET 247 | last post: by
3 posts views Thread by BjörnHolmberg | last post: by
2 posts views Thread by Dave | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.