Groups | Blog | Home
all groups > dotnet sdk > october 2005 >

dotnet sdk : Compiling dlls with vbc.exe


martinharvey via DotNetMonster.com
10/17/2005 12:00:00 AM
I would be really grateful if somone can help me with this:

I am trying to compile a dll from the commnd line with the following code:

vbc /debug /nologo /t:library /out:\worldshopdevelopement\bin\Catalog.dll /r:
System.dll /r:System.Data.dll \worldshopdevelopement\Catalog.vb

The vbc compiler is returning the message:

C:\worldshopdevelopement\Catalog.vb(11) : error BC30451: ?? 'CommandType' ????
??
?????

command.CommandType = CommandType.StoredProcedure
~~~~~~~~~~~
C:\worldshopdevelopement\Catalog.vb(15) : error BC30451: ?? 'CommandBehavior'
??
?????????

Return command.ExecuteReader(CommandBehavior.CloseConnection)
~~~~~~~~~~~~~~~
C:\worldshopdevelopement\Catalog.vb(20) : error BC30451: ??
'ConfigurationSettin
gs' ???????????

Return ConfigurationSettings.AppSettings("ConnectionString")

Would be really grateful if someone could tell me where i am going wrong

Many Thanks

Martin

For reference the .vb page is as follows:

Imports System.Data.SqlClient
Public Class Catalog
Public Shared Function SP_GetBB() As SqlDataReader
' Create the connection object
Dim connection As New SqlConnection(connectionString)
' Create and initialize the command object
Dim command As New SqlCommand("SP_GetBB", connection)
command.CommandType = CommandType.StoredProcedure
' Open the connection
connection.Open()
' Return a SqlDataReader to the calling function
Return command.ExecuteReader(CommandBehavior.CloseConnection)
End Function

Private Shared ReadOnly Property connectionString() As String
Get
Return ConfigurationSettings.AppSettings("ConnectionString")
End Get
End Property
Richard Grimes
10/17/2005 12:00:00 AM
[quoted text, click to view]

You're missing the appropriate Imports for the namespaces of the classes
that are being marked as an error. For example, for the error above you
must either explicitly call:

System.Diagnostics.ConfigurationSettings.AppSettings("ConnectionString")

or add a line:

Imports System.Diagnostics

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm

Richard Grimes
10/18/2005 12:00:00 AM
[quoted text, click to view]

Ah, now I see what the problem is.

Unfortunately Microsoft have confused issues with the names of their
assemblies - they appear to look as if they are named after namespaces,
but this is not correct. A namespace is just a prefix to the name of a
class, it has no bearing on the assembly where a class is defined. In
fact, an assembly can have types of several namespaces, and types of the
same namespace can be defined in several assemblies.

Most of the classes in System.Diagnostics are in the system.dll
assembly, there is no System.Diagnostics.dll assembly. However, the only
way to know for sure is to look up the class in the documentation.

[quoted text, click to view]

SqlCommand is in the System.Data.SqlClient namespace and is defined in
the system.data.dll assembly.

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlCommandClassTopic.asp?frame=true

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm

martinharvey via DotNetMonster.com
10/18/2005 8:43:04 AM
[quoted text, click to view]


Dear Richard

Thank you for your help with this.

I have tried adding "Imports System.Diagnostics" to the vb page. How do i
reference this on the command line?. I have tried using /r: System.
Diagnostics.dll but I get a 2017 compile error.

Do you have any thoughts about this and what do you think the missing
namespace could be for the "Command" error.

Once again many thaks for your help.

Martin


--
Message posted via DotNetMonster.com
martinharvey via DotNetMonster.com
10/19/2005 8:29:23 AM
[quoted text, click to view]

Thank you for your patience with this Richard

I am referencing both the system.data.dll and system.dll in the command
line as well as Imports System.Diagnostics in the .vb page but i am still
getting the same error i mentioned in my first query.

I am pulling my hair out with this

Any further thoughts

Thank you

Martin


--
Message posted via DotNetMonster.com
Richard Grimes
10/19/2005 2:28:30 PM
[quoted text, click to view]

Yes, sorry I should have tried to compile the code myself. Now I have
done, here's how I got it to compile.

You need Imports for System.Data, System.Data.SqlClient and
System.Configuration.

You need to reference two assemblies on the command line:
system.data.dll and system.dll

Finally, the connectionString is not defined anywhere. So either make it
a parameter of the function, or make it a constant.

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm

martinharvey via DotNetMonster.com
10/20/2005 8:46:49 AM
[quoted text, click to view]

Thank you once again Richard

I had tried the above combination before and got the same error . I think you
are right about defining the
connection string.

The connection string i have in the web file app settings is;

<add key="ConnectionString"
value="server=localhost;Trusted_Connection=true;database=worldshop" />

What would the exact syntax be for making this a constant or a parameter of
the function.

many thanks

martin


--
Message posted via DotNetMonster.com
Richard Grimes
10/20/2005 10:11:05 PM
[quoted text, click to view]

If it is in <appSettings> then you should read it from there:

Dim connection_string As String
connection_string =
ConfigurationSettings.AppSettings("ConnectionString")

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm

martinharvey via DotNetMonster.com
10/23/2005 7:08:56 AM
[quoted text, click to view]

Just a quick note to let you know i got it working

many many thanks for your help with this Richard


martin


--
AddThis Social Bookmark Button