473,396 Members | 2,018 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,396 software developers and data experts.

System.InvalidCastException: Cast from string " ERROR

Hi:
I have a VB.Net application that results in the error above on a
Win2000 PC. I do not see the error on WinXP PCs. Here are the lines of
code that has the problems:
Dim filename2 As String

filename2 = "C:\Documents and Settings\merklw\Desktop\New
Folder\01110511.HUP"

FileOpen(22, filename2, OpenMode.Input) 'This is where the error
occurs.
The file exists and can be opened with NotePad. This is strange to me
since I use the same type of open statement in other places within the
code.
What does the:
Cast from string "
message mean? Any ideas how to fix it?
Thanks,
Jim

Nov 21 '05 #1
8 2307
When you put a breakpoint on the line causing the error does the variable
filename2 still have it's value, or is it an empty string?

-Zorpy

"ra****@fauske.com" wrote:
Hi:
I have a VB.Net application that results in the error above on a
Win2000 PC. I do not see the error on WinXP PCs. Here are the lines of
code that has the problems:
Dim filename2 As String

filename2 = "C:\Documents and Settings\merklw\Desktop\New
Folder\01110511.HUP"

FileOpen(22, filename2, OpenMode.Input) 'This is where the error
occurs.
The file exists and can be opened with NotePad. This is strange to me
since I use the same type of open statement in other places within the
code.
What does the:
Cast from string "
message mean? Any ideas how to fix it?
Thanks,
Jim

Nov 21 '05 #2
The Win2000 PC does not have VB.net installed and I have limited access
to it. I did put some debugging info into the code (opened a text file
& wrote out the file name) and the specified name is what was written
to the debugging text file.

Nov 21 '05 #3
Try replacing the FileOpen with the .NET file classes:
File.Open("Path", FileMode.Open, FileAccess.Read)

I usually prefer to work with a reader:
Dim st As StreamReader = New StreamReader("Path")

"ra****@fauske.com" wrote:
Hi:
I have a VB.Net application that results in the error above on a
Win2000 PC. I do not see the error on WinXP PCs. Here are the lines of
code that has the problems:
Dim filename2 As String

filename2 = "C:\Documents and Settings\merklw\Desktop\New
Folder\01110511.HUP"

FileOpen(22, filename2, OpenMode.Input) 'This is where the error
occurs.
The file exists and can be opened with NotePad. This is strange to me
since I use the same type of open statement in other places within the
code.
What does the:
Cast from string "
message mean? Any ideas how to fix it?
Thanks,
Jim

Nov 21 '05 #4
When you say you have limited access what do you mean? Are you talking with
the view of Windows security?

I agree with the other user suggesting IO.StreamReader, but also look into
FileIOPermissions because there are a few people experiecing the same problem
& setting file permissions has overcome this error.

"Amiram Korach" wrote:
Try replacing the FileOpen with the .NET file classes:
File.Open("Path", FileMode.Open, FileAccess.Read)

I usually prefer to work with a reader:
Dim st As StreamReader = New StreamReader("Path")

"ra****@fauske.com" wrote:
Hi:
I have a VB.Net application that results in the error above on a
Win2000 PC. I do not see the error on WinXP PCs. Here are the lines of
code that has the problems:
Dim filename2 As String

filename2 = "C:\Documents and Settings\merklw\Desktop\New
Folder\01110511.HUP"

FileOpen(22, filename2, OpenMode.Input) 'This is where the error
occurs.
The file exists and can be opened with NotePad. This is strange to me
since I use the same type of open statement in other places within the
code.
What does the:
Cast from string "
message mean? Any ideas how to fix it?
Thanks,
Jim

Nov 21 '05 #5
I tried this, but it did not solve the problem. I have now found a XP
PC, that I have access to, that experiences the same problem. This XP
PC does not have VB.Net installed either. I have installed the .Net
SDK, but when the problem appears, I get the error box, but JIT does
not start. Any idea how I can get JIT to start?

Thanks,
Jim

Nov 21 '05 #6
I tried this, but it did not solve the problem. I have now found a XP
PC, that I have access to, that experiences the same problem. This XP
PC does not have VB.Net installed either. I have installed the .Net
SDK, but when the problem appears, I get the error box, but JIT does
not start. Any idea how I can get JIT to start?

Thanks,
Jim

Nov 21 '05 #7
No not Windows security. I mean the PC is physically about 800 miles
from here and I cannot remote desktop to it.

I tried the IO.StreamReader, but that did not fix the problem.

I checked the file permission, and all looks good.

I have now found a XP PC here that has the same problem. BUT, I cannot
get JIT to start. The XP PC here does not have VB.Net installed, but I
installed the .Net SDK.

Any ideas how to get JIT to work. I have been looking around, but have
not found how to do it.

Thanks,
Jim

Nov 21 '05 #8
No not Windows security. I mean the PC is physically about 800 miles
from here and I cannot remote desktop to it.

I tried the IO.StreamReader, but that did not fix the problem.

I checked the file permission, and all looks good.

I have now found a XP PC here that has the same problem. BUT, I cannot
get JIT to start. The XP PC here does not have VB.Net installed, but I
installed the .Net SDK.

Any ideas how to get JIT to work. I have been looking around, but have
not found how to do it.

Thanks,
Jim

Nov 21 '05 #9

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

Similar topics

3
by: karunakar | last post by:
Hi All Here iam getting this Error "Specified cast is not valid." My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error I was calling...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
4
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
10
by: Kiran | last post by:
Hi, I am trying to convert a string(Thu Jul 21 00:00:00 UTC+0100 200) to date. I get the following error Cast from string "Thu Jul 21 00:00:00 UTC+0100 200" to type 'Date' is not...
2
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) {...
1
by: Ratz | last post by:
Hello everyone! I'm new to this Forum! I've spent about 56 hours trying to solve a .NET VB Runtime error while Using a program.Ive contacted the developer of the program and he could not figure out...
8
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is...
0
by: woollymammoth | last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be an easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that record...
4
by: rsdev | last post by:
Hi, I have an InvalidCastException which is completely puzzling me. I have checked all the members in the stored procedure against my data provider and seems to be ok. Also in the stack trace it...
2
by: thithi | last post by:
Server Error in '/Assignment' Application. -------------------------------------------------------------------------------- Specified cast is not valid. Description: An unhandled exception...
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: 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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.