Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted (edited)

I have ported a VB6 program to VB.NET. The program needs to read blocks of bytes from a file. Here is an example of the sort of code I use in many places in the file:

       FileGet(FileNumber, GameText)

GameText is a one dimensional array of bytes. This works fine with option strict off. When I turn option strict on there is, quite understandably, an overload resolution failure. I tried casting GameText to a System.Array and instead of reading the data, the array I got was the unmodified array filled with zeros. I tried casting to an object and got a security error(?). I don't know which overload is being called but it must be FileGet(Integer, System.Array, [integer]) or FileGet(Integer, Object, [integer]). I would think the first which accepts an array.

 

I don't see how, but could the casting to type System.Array cause a problem with the ByRef argument (the array that I am passing)?

Am I wrong in expecting the first overload i mentioned to be the one that is called?

Can somebody please help me?

 

BTW: I would change it over to the filestream class but I am more familiar with the old vb6 way and more importantly there is a lot of code involved that would have to be changed. It is not out of the question but I would certainly rather not change all that code.

 

[Edit]The security error only happened once. Casting to an object seems to have the same effect as casting to an array.[/Edit]

Edited by snarfblam
[sIGPIC]e[/sIGPIC]
  • Leaders
Posted
Well, I've started converting my program over to filestreams and it looks like I only have about 100 fileget/fileputs left to replace, but just in case anyone who knows the answer to the above question, I am still very curious.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...