Newbie - Error with command line vbc but not with vs.net?

Z

Zenobia

What is wrong with this snippet?

It is a modification from Stephen Walther's ASP.NET Unleashed,
1e, page 734-5:

+++++ +++++ +++++ +++++ +++++
Public Class ProductsHandler
... some code ...

objContext.Response.Write ("<html>" & vbCrLf & "<title>")

... some more code ...

ReadOnly Property vbCrLf() As String
Get
Return Chr(13) & Chr(10)
End Get
End Property

... some more code ...

End Class

+++++ +++++ +++++ +++++ +++++

(a) When I rebuild my dll using Visual Studio 2003 I get NO
errors:

Rebuild All: 1 succeeded, 0 failed, 0 skipped

(b) When I build using this command line:

vbc.exe /t:library
/r:System.dll,System.Web.dll,System.Data.dll ProductsHandler.vb

I get an error:

ProductsHandler.vb(44) : error BC30451: Name 'Chr' is not
declared.

+++++ +++++ +++++ +++++ +++++

Why is the error picked up by the command line but not by
VS.NET?

Can someone recommend a good book on VB.NET for those used to
using VBScript at lot and VB6 a little? Ideally the book should
also cover VS.NET
 
Z

Zenobia

On Sat, 26 Jun 2004 05:49:00 +0100, Zenobia

It still doesn't work.

What additional library dll do I need to specify as a command
line switch to get either vbNewLine or ControlChars.NewLine to
work and how can I find this information for myself (in future)?

More details are bottom posted.
What is wrong with this snippet?

It is a modification from Stephen Walther's ASP.NET Unleashed,
1e, page 734-5:

+++++ +++++ +++++ +++++ +++++
Public Class ProductsHandler
... some code ...

objContext.Response.Write ("<html>" & vbCrLf & "<title>")

... some more code ...

ReadOnly Property vbCrLf() As String
Get
Return Chr(13) & Chr(10)
End Get
End Property

... some more code ...

End Class

+++++ +++++ +++++ +++++ +++++

(a) When I rebuild my dll using Visual Studio 2003 I get NO
errors:

Rebuild All: 1 succeeded, 0 failed, 0 skipped

(b) When I build using this command line:

vbc.exe /t:library
/r:System.dll,System.Web.dll,System.Data.dll ProductsHandler.vb

I get an error:

ProductsHandler.vb(44) : error BC30451: Name 'Chr' is not
declared.

+++++ +++++ +++++ +++++ +++++

Why is the error picked up by the command line but not by
VS.NET?

Can someone recommend a good book on VB.NET for those used to
using VBScript at lot and VB6 a little? Ideally the book should
also cover VS.NET

I included the line:

Imports System.Char

at the top before my class declaration and changed the property
to:

ReadOnly Property vbCrLf() As String
Get
Return ControlChars.NewLine
End Get
End Property

or alternatively to:

ReadOnly Property vbCrLf() As String
Get
Return vbNewLine
End Get
End Property

The command line compiler still fails in the same place with:

error BC30451: Name 'ControlChars' is not declared.

or

error BC30451: Name 'vbNewLine' is not declared.

Either of these 2 techniques work with VS.NET but not with the
command line.

This is the command line I'm using:

vbc.exe /t:library /r:System.dll,System.Web.dll,System.Data.dll
ProductsHandler.vb

This is where it's located:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\

This is the version of the command line compiler:

Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573

Visual Studio version is:
Microsoft Development Environment 2003, version: 7.1.3088
Microsoft .NET Framework, version: 1.1.4322

Using the vbNewLine and leaving out:

Imports System.Char

works with VS.NET but still gives the same error with the
command line.
 
T

Tom Shelton

What is wrong with this snippet?

It is a modification from Stephen Walther's ASP.NET Unleashed,
1e, page 734-5:

+++++ +++++ +++++ +++++ +++++
Public Class ProductsHandler
... some code ...

objContext.Response.Write ("<html>" & vbCrLf & "<title>")

... some more code ...

ReadOnly Property vbCrLf() As String
Get
Return Chr(13) & Chr(10)
End Get
End Property

... some more code ...

End Class

+++++ +++++ +++++ +++++ +++++

(a) When I rebuild my dll using Visual Studio 2003 I get NO
errors:

Rebuild All: 1 succeeded, 0 failed, 0 skipped

(b) When I build using this command line:

vbc.exe /t:library
/r:System.dll,System.Web.dll,System.Data.dll ProductsHandler.vb

I get an error:

ProductsHandler.vb(44) : error BC30451: Name 'Chr' is not
declared.

+++++ +++++ +++++ +++++ +++++

Why is the error picked up by the command line but not by
VS.NET?

Can someone recommend a good book on VB.NET for those used to
using VBScript at lot and VB6 a little? Ideally the book should
also cover VS.NET

try adding microsoft.visualbasic.dll to your command line (in the
references list).
 
T

Tom Shelton

On Sat, 26 Jun 2004 05:49:00 +0100, Zenobia

It still doesn't work.

What additional library dll do I need to specify as a command
line switch to get either vbNewLine or ControlChars.NewLine to
work and how can I find this information for myself (in future)?

More details are bottom posted.


I included the line:

Imports System.Char

at the top before my class declaration and changed the property
to:

ReadOnly Property vbCrLf() As String
Get
Return ControlChars.NewLine
End Get
End Property

or alternatively to:

ReadOnly Property vbCrLf() As String
Get
Return vbNewLine
End Get
End Property

The command line compiler still fails in the same place with:

error BC30451: Name 'ControlChars' is not declared.

or

error BC30451: Name 'vbNewLine' is not declared.

Either of these 2 techniques work with VS.NET but not with the
command line.

This is the command line I'm using:

vbc.exe /t:library /r:System.dll,System.Web.dll,System.Data.dll
ProductsHandler.vb

This is where it's located:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\

This is the version of the command line compiler:

Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573

Visual Studio version is:
Microsoft Development Environment 2003, version: 7.1.3088
Microsoft .NET Framework, version: 1.1.4322

Using the vbNewLine and leaving out:

Imports System.Char

works with VS.NET but still gives the same error with the
command line.

vbCrLf is already a constant defined in the vb.net runtime... It's
possible that this is confusing the compiler, but it is hard to tell
without seeing the rest of the code.
 
Z

Zenobia

try adding microsoft.visualbasic.dll to your command line (in the
references list).

Thank you Tom, that worked.

added:
Imports Microsoft.VisualBasic

and changed the command line to:
vbc.exe /t:library
/r:Microsoft.VisualBasic.dll,System.dll,System.Web.dll,System.Data.dll
ProductsHandler.vb

removed the vbCrLf property and replaced vbCrLf with vbNewLine
throughout. Presumably I could have kept vbCrLf.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top