473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

no accessible 'GetBytes' can be called with these arguments

les
I'm trying to http post xml data to a remote server and I get this
error:

BC30518: Overload resolution failed because no accessible 'GetBytes'
can be called with these arguments:

Line 20: Dim d As Byte() =
System.Text.Encoding.ASCII.GetBytes(readStream)

The aspx page is shown below. Can anyone help?
Thanks
Leslie

<%@ Page Language="VB" debug="True"%>
<%@ import namespace="system.io"%>
<%@ Import Namespace="System.Text" %>
<%@ import namespace="system.xml"%>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Web" %>
<Script Language="vb" runat="server">
Sub Page_Load(s as object, e as eventargs)

'Creates a streamreader from an xml file
Dim HttpWReq As HttpWebRequest =
CType(WebRequest.Create("http://server/datafile.xml"), HttpWebRequest)
Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(),
HttpWebResponse)
Dim receiveStream As Stream = HttpWResp.GetResponseStream()
Dim encode As Encoding =
system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)

'post readstream to target server
Dim web As New System.Net.WebClient()
web.Headers.Add("Content-Type", "text/xml")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(readStream)
Dim res As Byte() = web.UploadData("http://targetserver/postpage",
"POST", d)
Console.Write(System.Text.Encoding.ASCII.GetString (res))
response.write (System.Text.Encoding.ASCII.GetString(res))

readStream.Close()
HttpWResp.Close()

End Sub
</script>

Nov 20 '05 #1
16 3986
ASCIIEncoding.GetBytes encodes a Unicode character array or a string. You're passing a StreamReader, which is not among the overloads availble for this method. The list of available overloads is here

http://msdn.microsoft.com/library/de...bytestopic.asp
Nov 20 '05 #2
<les> schrieb

BC30518: Overload resolution failed because no accessible
'GetBytes' can be called with these arguments:

Line 20: Dim d As Byte() =
System.Text.Encoding.ASCII.GetBytes(readStream)


Right, you can not pass a stream to the GetBytes method. Pass a String or an
array of Chars.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
les
Thanks Armin, but I'm a bit lost here. How would I change my code to
pass a string or array of chars?

Thanks
Leslie
On Sat, 24 Apr 2004 01:16:04 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
<les> schrieb

BC30518: Overload resolution failed because no accessible
'GetBytes' can be called with these arguments:

Line 20: Dim d As Byte() =
System.Text.Encoding.ASCII.GetBytes(readStream)


Right, you can not pass a stream to the GetBytes method. Pass a String or an
array of Chars.


<%@ Page Language="VB" debug="True"%>
<%@ import namespace="system.io"%>
<%@ Import Namespace="System.Text" %>
<%@ import namespace="system.xml"%>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Web" %>
<Script Language="vb" runat="server">
Sub Page_Load(s as object, e as eventargs)

'Creates a streamreader from an xml file
Dim HttpWReq As HttpWebRequest =
CType(WebRequest.Create("http://server/datafile.xml"), HttpWebRequest)
Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(),
HttpWebResponse)
Dim receiveStream As Stream = HttpWResp.GetResponseStream()
Dim encode As Encoding =
system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)

'post readstream to target server
Dim web As New System.Net.WebClient()
web.Headers.Add("Content-Type", "text/xml")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(readStream)
Dim res As Byte() = web.UploadData("http://targetserver/postpage",
"POST", d)
Console.Write(System.Text.Encoding.ASCII.GetString (res))
response.write (System.Text.Encoding.ASCII.GetString(res))

readStream.Close()
HttpWResp.Close()

End Sub
</script>
Nov 20 '05 #4
<les> schrieb
Thanks Armin, but I'm a bit lost here. How would I change my code
to pass a string or array of chars?


When you create the Streamreader, you can pass an Encoding object that
specifies the encoding of the chars in the stream. After reading a string
from the Stream, you can pass it to the GetBytes method of an Encoding
object to get the encoded byte array.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
les
I'm creating the streamreader ok , but can't work out how to do the
rest. This bit encodes the stream as iso-8859-1, but how do I convert
this to a string?

system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)
On Sat, 24 Apr 2004 16:57:22 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
<les> schrieb
Thanks Armin, but I'm a bit lost here. How would I change my code
to pass a string or array of chars?


When you create the Streamreader, you can pass an Encoding object that
specifies the encoding of the chars in the stream. After reading a string
from the Stream, you can pass it to the GetBytes method of an Encoding
object to get the encoded byte array.


<Script Language="vb" runat="server">
Sub Page_Load(s as object, e as eventargs)

'Creates a streamreader from an xml file
Dim HttpWReq As HttpWebRequest =
CType(WebRequest.Create("http://server/datafile.xml"), HttpWebRequest)
Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(),
HttpWebResponse)
Dim receiveStream As Stream = HttpWResp.GetResponseStream()
Dim encode As Encoding =
system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)

'post readstream to target server
Dim web As New System.Net.WebClient()
web.Headers.Add("Content-Type", "text/xml")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(readStream)
Dim res As Byte() = web.UploadData("http://targetserver/postpage",
"POST", d)
Console.Write(System.Text.Encoding.ASCII.GetString (res))
response.write (System.Text.Encoding.ASCII.GetString(res))

readStream.Close()
HttpWResp.Close()

End Sub
</script>
Nov 20 '05 #6
<les> schrieb
I'm creating the streamreader ok , but can't work out how to do
the rest. This bit encodes the stream as iso-8859-1, but how do I
convert this to a string?

system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)


What do you want to convert to a string? If the text in the stream is
encoded in "ISO-8859-1", you can now use the stream to read from
(readStream.readline or readStream.readtoend).

Later you can convert the string to a byte array by passing it to the
GetBytes method of an Encoding object.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7
les
Now I'm really confused....I thought you were telling me I need to
convert the streamreader to a string before it can be passed to the
getbytes method.

Is it possible you could show me how to modify the code? I'm quite
lost here
Thanks
Leslie
On Sat, 24 Apr 2004 17:36:43 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
<les> schrieb
I'm creating the streamreader ok , but can't work out how to do
the rest. This bit encodes the stream as iso-8859-1, but how do I
convert this to a string?

system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)


What do you want to convert to a string? If the text in the stream is
encoded in "ISO-8859-1", you can now use the stream to read from
(readStream.readline or readStream.readtoend).

Later you can convert the string to a byte array by passing it to the
GetBytes method of an Encoding object.

<Script Language="vb" runat="server">
Sub Page_Load(s as object, e as eventargs)
'Creates a streamreader from an xml file
Dim HttpWReq As HttpWebRequest =
CType(WebRequest.Create("http://server/datafile.xml"), HttpWebRequest)
Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(),
HttpWebResponse)
Dim receiveStream As Stream = HttpWResp.GetResponseStream()
Dim encode As Encoding =
system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)

'post readstream to target server
Dim web As New System.Net.WebClient()
web.Headers.Add("Content-Type", "text/xml")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(readStream)
Dim res As Byte() = web.UploadData("http://targetserver/postpage",
"POST", d)
Console.Write(System.Text.Encoding.ASCII.GetString (res))
response.write (System.Text.Encoding.ASCII.GetString(res))

readStream.Close()
HttpWResp.Close()

End Sub
</script>
Nov 20 '05 #8
<les> schrieb
Now I'm really confused....I thought you were telling me I need to
convert the streamreader to a string before it can be passed to
the getbytes method.

Is it possible you could show me how to modify the code? I'm quite
lost here


I don't know what's your intention. You wanted to get the bytes from a
stream in a certain encoding, right?
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #9
les
On Sat, 24 Apr 2004 20:00:49 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
<les> schrieb
Now I'm really confused....I thought you were telling me I need to
convert the streamreader to a string before it can be passed to
the getbytes method.

Is it possible you could show me how to modify the code? I'm quite
lost here


I don't know what's your intention. You wanted to get the bytes from a
stream in a certain encoding, right?


Yes but getting the following error:

BC30518: Overload resolution failed because no accessible 'GetBytes'
can be called with these arguments:

Line 20: Dim d As Byte() =
System.Text.Encoding.ASCII.GetBytes(readStream)
<%@ Page Language="VB" debug="True"%>
<%@ import namespace="system.io"%>
<%@ Import Namespace="System.Text" %>
<%@ import namespace="system.xml"%>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Web" %>
<Script Language="vb" runat="server">
Sub Page_Load(s as object, e as eventargs)

'Creates a streamreader from an xml file
Dim HttpWReq As HttpWebRequest =
CType(WebRequest.Create("http://server/datafile.xml"), HttpWebRequest)
Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(),
HttpWebResponse)
Dim receiveStream As Stream = HttpWResp.GetResponseStream()
Dim encode As Encoding =
system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)

'post readstream to target server
Dim web As New System.Net.WebClient()
web.Headers.Add("Content-Type", "text/xml")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(readStream)
Dim res As Byte() = web.UploadData("http://targetserver/postpage",
"POST", d)
Console.Write(System.Text.Encoding.ASCII.GetString (res))
response.write (System.Text.Encoding.ASCII.GetString(res))

readStream.Close()
HttpWResp.Close()

End Sub
</script>

Nov 20 '05 #10
<les> schrieb
On Sat, 24 Apr 2004 20:00:49 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
<les> schrieb
Now I'm really confused....I thought you were telling me I need
to convert the streamreader to a string before it can be passed
to the getbytes method.

Is it possible you could show me how to modify the code? I'm
quite lost here


I don't know what's your intention. You wanted to get the bytes from
a stream in a certain encoding, right?


Yes but getting the following error:


Now we are as far as yesterday.

What do you want to do?? What is your intention??

You can NOT pass a streamreader to the GetBytes function. You can pass a
string to the GetBytes function. I don't know which string you want to pass.
I assume, you first want to read the string from the Streamreader and then
pass it to GetBytes. Is this right or wrong? If it is right, use the
Streamreaders ReadLine or Readtoend method. Then you have a string and you
can pass it to GetBytes. Where is the problem with doing it? Or is it not
what you want to do? I don't know.
--
Armin

Nov 20 '05 #11
les
Thanks for persevering with me Armin.
It sounds like you are describing exactly what I want to do, but I
don't know how to apply the ReadLine or Readtoend method to my
existing code.
Leslie
On Sat, 24 Apr 2004 20:18:39 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
<les> schrieb
On Sat, 24 Apr 2004 20:00:49 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
><les> schrieb
>> Now I'm really confused....I thought you were telling me I need
>> to convert the streamreader to a string before it can be passed
>> to the getbytes method.
>>
>> Is it possible you could show me how to modify the code? I'm
>> quite lost here
>
>I don't know what's your intention. You wanted to get the bytes from
> a stream in a certain encoding, right?


Yes but getting the following error:


Now we are as far as yesterday.

What do you want to do?? What is your intention??

You can NOT pass a streamreader to the GetBytes function. You can pass a
string to the GetBytes function. I don't know which string you want to pass.
I assume, you first want to read the string from the Streamreader and then
pass it to GetBytes. Is this right or wrong? If it is right, use the
Streamreaders ReadLine or Readtoend method. Then you have a string and you
can pass it to GetBytes. Where is the problem with doing it? Or is it not
what you want to do? I don't know.


Nov 20 '05 #12
<les> schrieb
Thanks for persevering with me Armin.
It sounds like you are describing exactly what I want to do, but I
don't know how to apply the ReadLine or Readtoend method to my
existing code.
Leslie

You don't know how to call a method?

- WebRequest.Create
- HttpWReq.GetResponse
- HttpWResp.GetResponseStream
- Encoding.GetEncoding

These are all method calls in your code, so I think you do know how to call
a method. Sorry, I don't understand.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #13
dim s as string
dim d as byte()

s = readStream.Readline

d = System.Text.Encoding.ASCII.GetBytes(s)

This reads a line, then gets the bytes encoded using ASCII encoding.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #14
les
I'm not sure I can describe the problem any better. I don't have much
experience of vb.net, so I'm hoping someone can show how to change my
code to use readline or readtoend as you sugested.
On Sat, 24 Apr 2004 20:38:00 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
<les> schrieb
Thanks for persevering with me Armin.
It sounds like you are describing exactly what I want to do, but I
don't know how to apply the ReadLine or Readtoend method to my
existing code.
Leslie

You don't know how to call a method?

- WebRequest.Create
- HttpWReq.GetResponse
- HttpWResp.GetResponseStream
- Encoding.GetEncoding

These are all method calls in your code, so I think you do know how to call
a method. Sorry, I don't understand.


Nov 20 '05 #15
<les> schrieb
I'm not sure I can describe the problem any better. I don't have
much experience of vb.net, so I'm hoping someone can show how to
change my code to use readline or readtoend as you sugested.


You don't tell me what you want, so I can't help you.

--
Armin

Nov 20 '05 #16
les
That's what I needed. Thanks again Armin for your help.

Leslie

On Sat, 24 Apr 2004 20:41:25 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
dim s as string
dim d as byte()

s = readStream.Readline

d = System.Text.Encoding.ASCII.GetBytes(s)

This reads a line, then gets the bytes encoded using ASCII encoding.


Nov 20 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's...
5
by: cloudx | last post by:
Hi there, I have got the following piece of VB code to be translated to C#, I used System.Text.Encoding.Default.GetBytes(myStr, 1, 10, aBytes, 0) but the result of aBytes is different from what...
1
by: steve | last post by:
I am trying to create an XSLT Transform but keep getting the same problem. Overload resolution failed because no accessible 'Transform' can be called with these arguments. I create a reference...
0
by: bcobra | last post by:
What am I doing wrong? the code: age Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %> <%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls"...
9
by: TechN00b | last post by:
I'm trying to write a quick commandline app that takes a string from the commandline and returns a formatted md5 hash. Unfortunately the code won't comple and returns an error of "No accessible...
0
by: tshad | last post by:
I am getting the following error which makes no sense. No accessible overloaded If you look at the error, there is one overloaded function that can be called (int, string, int, int). The...
3
by: tshad | last post by:
I am getting the following error which makes no sense. I am doing this in asp.net. I get the following error: No accessible overloaded If you look at the error, there is one overloaded...
10
by: tshad | last post by:
I have a Dll I created in VS 2000. The namespace is MyFunctions and the Class is CryptoUtil. I have a program that is using the Class but it can't access it directly. I have a class (below)...
2
by: Bart | last post by:
Hi, i get the error "BC30518:Overload resolution failed because no accessible 'Join' can be called with these arguments" at line: hvd = Join(hvertp, ",") Any idea what's wrong here? Thanks...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.