all groups > vb.net upgrade > october 2003 >
You're in the

vb.net upgrade

group:

System.NullReferenceException gets raised when not raised with VB 6 code



System.NullReferenceException gets raised when not raised with VB 6 code Howard Kaikow
10/18/2003 9:02:07 AM
vb.net upgrade: If a VB 6 module contains, say:

strQuote = "H""K"

strLogFile = "Write.txt"
intFile = FreeFile
Open strLogFile For Output As #intFile
Write #intFile, strQuote

The code excutes as expected.

The Help for the VB 6 Write states

"Note You should not write strings that contain embedded quotation marks,
for example, "1,2""X" for use with the Input # statement: Input # parses
this string as two complete and separate strings."

That does not preclude my writing such strings to the file.

The Help for the VB .NET WriteLine states:
"Note You should not write strings that contain embedded quotation marks
for use with the Input function (for example, "1,2""X"): the Input function
parses this string as two complete and separate strings."
Again, that does not preclude my writing such strings to the file.

However, when upgraded to VB .NET 2002, the corresponding code generates a
System.NullReferenceException.
So the VB .NET Help file is incorrect for the WriteLine statement.

Is there a list of known errors in the Help file?
--
http://www.standards.com/; See Howard Kaikow's web site.

Re: System.NullReferenceException gets raised when not raised with VB 6 code Jay B. Harlow [MVP - Outlook]
10/18/2003 9:59:06 AM
Howard,
What does your VB.NET code look like?

Without your actual VB.NET code we cannot verify that it is a documentation
bug verses a logic bug, verses an upgrade wizard bug...

Also did you upgrade a VB6 program with this code? or did you manually enter
the equivalent from scratch?

I used the VB.NET 2003 Upgrade VB6 code (that allows you to upgrade just a
snippet). I did not receive a Null Reference Exception. It wrote the string
to the file as expected.

Hope this helps
Jay

[quoted text, click to view]

Re: System.NullReferenceException gets raised when not raised with VB 6 code Howard Kaikow
10/18/2003 1:34:04 PM
It was an upgrade from a VB 6 project, which is why I asked in this
newsgroup.
I used .NET 2002.
I'll have to try it with .NET 2003, could be they fixed the problem in
2003.

--
http://www.standards.com/; See Howard Kaikow's web site.
[quoted text, click to view]

Re: System.NullReferenceException gets raised when not raised with VB 6 code Howard Kaikow
10/18/2003 2:42:42 PM
See http://www.standards.com/index.html#Temporary and download the
WriteLine2002-001.zip file.

File contains:

1. VB 6 project
2. VB .NET 2002 Project as upgraded from VBP file.
3. VB .NET 2003 Project as upgraded from VBP file.

System.NullReferenceException gets raised only in VB .NET 2002 project.

I sure hope MSFT fixes this in VB .NET 2002.

--
http://www.standards.com/; See Howard Kaikow's web site.

Re: System.NullReferenceException gets raised when not raised with VB 6 code Jay B. Harlow [MVP - Outlook]
10/18/2003 3:55:39 PM
Howard,
As your two projects have demonstrated. VB.NET 2003 does not have the
problem, while VS.NET 2002 does.

[quoted text, click to view]

I sincerely do not see any reason why MS would retrofit the fix into VB.NET
2002, especially when it was fixed in VS.NET 2003 and the beta for VB.NET
2004 will be available at PDC later this month. However I could be wrong.

If upgrading to VS.NET 2003 really is not an option you could try contacting
MS support directly. They may, that's a really big may, have a fix
available. http://support.microsoft.com/default.aspx?pr=cntactms, of course
if they do not it will cost you a support call!

The other option for staying on VS.NET 2002 is to convert the code from
using the Microsoft.VisualBasic.FileSystem class (FileOpen, WriteLine,
FileClose) to using the .NET Framework and use the classes in System.IO
namespace instead (FileStream & TextReader & TextWriter). Depending on how
much code you have this will be an easy conversion to a very hard
conversion.

Hope this helps
Jay


[quoted text, click to view]

Re: System.NullReferenceException gets raised when not raised with VB 6 code Jay B. Harlow [MVP - Outlook]
10/19/2003 9:49:26 AM
Howard,
[quoted text, click to view]
Interesting thought, try it.

My concern is it is a bug is in the 1.0 Microsoft.VisualBasic.dll assembly
itself, which means although you have a 1.1 assembly (the executable) you
would still be using the buggy code.

Remember in VB.NET that functions such are FileOpen, WriteLine & FileClose
are function class into the FileSystem class, this code exists in an
assembly (Microsoft.VisualBasic.dll).

The Microsoft.VisualBasic.dll assembly is installed as part of the
framework.

Hope this helps
Jay

[quoted text, click to view]

Re: System.NullReferenceException gets raised when not raised with VB 6 code Howard Kaikow
10/19/2003 10:14:56 AM
It is useful to write code in VB .NET 2003 and build a .exe that can run
with either version of the .NET Framework.
I do not know if the bug would show up in that case.

--
http://www.standards.com/; See Howard Kaikow's web site.
[quoted text, click to view]

Re: System.NullReferenceException gets raised when not raised with VB 6 code Howard Kaikow
10/19/2003 3:11:32 PM
Built a config file in .NET 2003.

Ran the VB .NE T2003 .exe in .NET 2002 environment.
Bug still occurs even tho .exe was built with VB .NET 2003.

--
http://www.standards.com/; See Howard Kaikow's web site.
[quoted text, click to view]

AddThis Social Bookmark Button