Problems compiling with vbc.exe due to the project namespace

G

Guest

I have been developing web apps in Visual Studio 2003, but since the other
developers in my office don't use Visual Studio, I may have to stop too
unless there is an efficient way for them to compile the code outside of
Visual Studio if they need to adjust something I created.

I have been trying to use vbc.exe, but I'm having problems with references
to the DataSet I have created. Multiple pages reference my dataset -
"DataSet1", ... let's say such as:
Me.DataSet11 = New MyProject.DataSet1.

I added: Imports MyProject.DataSet1
to each page as necessary, but vbc.exe returns "Namespace or type 'DataSet1'
for the Imports 'MyProject' cannot be found. (If I try: Imports MyProject
instead, I get "Namespace or type 'MyProject' for the Imports 'MyProject'
cannot be found.)

Whether I add the Imports statements to the pages or not, I get a lot of
messages from vbc.exe like "Type 'MyProject.DataSet1' is not defined."

I thought it might have something to do with the references - /r in vbc.exe,
but of course I can't add MyProject.dll as a reference since it is what I'm
trying to build!

Right now, my vbc.exe command looks like:
vbc.exe /target:library /out:bin/MyProject.dll
/r:System.dll,System.Web.dll,System.Data.dll,System.Drawing.dll,System.XML.dll page1.aspx.vb page2.aspx.vb
(the /r section is actually much longer - I was getting other errors, but
added the .dll files as necessary to clear them up)

Thanks,
Scott Thompson
 
C

Chris Dunaway

sjt003 said:
I have been developing web apps in Visual Studio 2003, but since the other
developers in my office don't use Visual Studio, I may have to stop too
unless there is an efficient way for them to compile the code outside of
Visual Studio if they need to adjust something I created.

I have been trying to use vbc.exe, but I'm having problems with references
to the DataSet I have created. Multiple pages reference my dataset -
"DataSet1", ... let's say such as:
Me.DataSet11 = New MyProject.DataSet1.

I added: Imports MyProject.DataSet1
to each page as necessary, but vbc.exe returns "Namespace or type 'DataSet1'
for the Imports 'MyProject' cannot be found. (If I try: Imports MyProject
instead, I get "Namespace or type 'MyProject' for the Imports 'MyProject'
cannot be found.)

Whether I add the Imports statements to the pages or not, I get a lot of
messages from vbc.exe like "Type 'MyProject.DataSet1' is not defined."

I thought it might have something to do with the references - /r in vbc.exe,
but of course I can't add MyProject.dll as a reference since it is what I'm
trying to build!

Right now, my vbc.exe command looks like:
vbc.exe /target:library /out:bin/MyProject.dll
/r:System.dll,System.Web.dll,System.Data.dll,System.Drawing.dll,System.XML.dll page1.aspx.vb page2.aspx.vb
(the /r section is actually much longer - I was getting other errors, but
added the .dll files as necessary to clear them up)

Inside VS, do you use the Namespace statement? Be aware that in
addition to the Namespace statement, the VB projects have a root
namespace that affects the names of all the namespaces you declare.
This can be found in the project properties.

Thus, if your root namespace for the project is something like:
Com.MyCompany

and in your code you use a Namespace statement:

Namespace MyNameSpace

Public Class MyClass
End Class

End Namespace

Then the fully qualified name for this class is:
Com.MyCompany.MyNameSpace.MyClass.

Perhaps this is what is causing your troubles? If not, can you show us
the code where the error is hitting?

Chris
 
G

Guest

Chris,

I'm not using the namespace statement. The name of the project namespace in
my example would by "MyProject".

OK, I just made a simple project for the sake of example. I named the
project "MyProject". When I look at the properties of the project, the root
namespace is named "MyProject".

There is one webform - Webform1.aspx. I added a DataAdapter to it and
generated a dataset named DataSet1 (DataSet1.xsd).

Here is the code (all system generated), the vbc.exe command is below too:
Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.DataSet11 = New MyProject.DataSet1
CType(Me.DataSet11,
System.ComponentModel.ISupportInitialize).BeginInit()
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT USER_NAME() AS UserName"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "deleted by poster - a valid
string existed"
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New System.Globalization.CultureInfo("en-US")
CType(Me.DataSet11,
System.ComponentModel.ISupportInitialize).EndInit()

End Sub
Protected WithEvents SqlDataAdapter1 As
System.Data.SqlClient.SqlDataAdapter
Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Protected WithEvents DataSet11 As MyProject.DataSet1

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class

It compiles without a problem and loads the page in Visual Studio

I run the following vbc.exe command:
vbc.exe /target:library /out:bin/MyProject.dll /r:S
ystem.dll,System.Data.dll,System.Drawing.dll,System.Web.dll WebForm1.aspx.vb

It returns the following error:
C:\Inetpub\wwwroot\MyProject\WebForm1.aspx.vb(11) : error BC30002: Type
'MyProje
ct.DataSet1' is not defined.

Me.DataSet11 = New MyProject.DataSet1
~~~~~~~~~~~~~~~~~~
C:\Inetpub\wwwroot\MyProject\WebForm1.aspx.vb(38) : error BC30002: Type
'MyProje
ct.DataSet1' is not defined.

Protected WithEvents DataSet11 As MyProject.DataSet1
~~~~~~~~~~~~~~~~~~


Thanks,
Scott
 

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