namespace confusion

  • Thread starter Thread starter Buz Waitz
  • Start date Start date
B

Buz Waitz

I'm a newbie. I've created a datalayer class which I creatively called
sqlAccess and placed in a namespace I just as creatively called
MyDomain.DataAccessLayer. (Well now, I didn't actually use "MyDomain" but
you know how that works.) And now I'm working on the business logic layer.
When I import the namespace, intellisense completes the name for me,
accurately, but then I get the squiggle of death that says, when I mouse
over it, "Namespace or type 'DataAcessLayer' for the Imports
'MyDomain.DataAccessLayer' cannot be found." And, sure enough, it does not
recognize the sqlAccess class/object either. What do I need to do? And if
you say to set up a reference to the dll, how do I do that? Please?

Thank you
 
Right click on references, chose 'add reference'. Browse for you dll, and
add it as a reference.

There is no way for the ide to know about all the dlls you want to reference
in the project, as you could have any number of them anywhere on your
computer. That's why you have to explicitly reference all DLL's you need in
the project.
 
Thank you. The reason I asked how to reference the dll is because when I go
to add the reference, it does not see the project. Do I need to build it
first? If so, I guess I need to comment out all the import statements that
are not working right now. And how is it that intellisense knows about the
namespace? Hmm. At this point, I know I need ot add the reference. How do I
find the dll?

Thank you
 
Buz,

* "Buz Waitz said:
I'm a newbie. I've created a datalayer class which I creatively called
sqlAccess and placed in a namespace I just as creatively called
MyDomain.DataAccessLayer. (Well now, I didn't actually use "MyDomain" but
you know how that works.) And now I'm working on the business logic layer.
When I import the namespace, intellisense completes the name for me,
accurately, but then I get the squiggle of death that says, when I mouse
over it, "Namespace or type 'DataAcessLayer' for the Imports
'MyDomain.DataAccessLayer' cannot be found." And, sure enough, it does not
recognize the sqlAccess class/object either. What do I need to do? And if
you say to set up a reference to the dll, how do I do that? Please?

I don't understand why AutoComplete works if there is no reference set,
but are you sure the component implementing the layer is referenced from
your project? You can set a reference by selecting the project's
"References" folder in the solution explorer and then choosing the
appropriate command from its context menu.
 
The DLLs you see there, are those in the GAC (you can look this up if you
don't know what that is).

As I said in the previous post, you need to browse for your DLL. And yes,
if you have not compiled the other project, then no DLL was generated, and
all you have is some VB files, which is just text, and is not executable
code.
 
Buz Waitz said:
Thank you. The reason I asked how to reference the dll is because when I go
to add the reference, it does not see the project. Do I need to build it
first? If so, I guess I need to comment out all the import statements that
are not working right now. And how is it that intellisense knows about the
namespace? Hmm. At this point, I know I need ot add the reference. How do I
find the dll?

Suppose you have ProjectA and ProjectB. You cannot make ProjectA depend on
ProjectB and ProjectB depend on ProjectA both. You have to choose the main
project, satelite DLL projects and reference DLL projects in main project.

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation
 
Hi Buz,

Thanks for posting in the community.

Do you have any concern on this issue?
If so, please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Yes, I guess I'm still having trouble. I did try building the solution
which contains both projects. I commented out any references to the data
access namespace in the business logic layer before building. Then,
afterward, I looked to see if I could find the dll and could not.

I really am new to this. I was trying to work with the .NET time tracker
example as my model and in that example, the data access layer name
space is imported into business layer components. What did they need to
do to be able to do that? Because even though intellisense will complet
the import statement for me with the correct namespace specification,
Visual Studio does not recognize it.

Thank you
 
Hi Buz,

Thanks for your quickly reply!

Here I write some steps on reference the project in the same solution, you
may follow them to see if this can help you.

In the solution you have two project one is the class library(CLS1), the
other is the Console Application(TestNamespace)

1. Create a new solution and add a new console application project named
TestNamespace.
2. Add a new class library project named Cls1 in the solution above.
3. Write code in the Cls1 as below..( do not include the content in the <>)

<Cls1:Class1.vb>
Namespace MyDomain.DataAccessLayer
Public Class sqlAccess
Public Sub TestClass()
Console.WriteLine("Run from code")
End Sub
End Class
End Namespace
</Cls1:Class1.vb>

4. add reference to the Cls1 by right click on the Reference in the
TestNamespace project,select add reference
5. in the add reference dialog, select Projects, double click on the Cls1
so that it will appear in the selected components.

6.Write the code below in the TestNamespace project as below.( do not
include the content in the <>)

<TestNamespace:Module1.vb>
Imports Cls1.MyDomain.DataAccessLayer
Module Module1
Sub Main()
Dim o As New sqlAccess
o.TestClass()
End Sub
End Module
</TestNamespace:Module1.vb>

7. Press Ctrl+Alt+B to build the solution.
8.Press Ctrl+F5 to run the project.


For detailed information about Namespaces, take a look at the links below.
Visual Basic Language Concepts
Namespaces
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/
vaconNamespaces.asp

Visual Basic Language Concepts
References and the Imports Statement
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/
vaconReferencesImportsStatement.asp


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Buz,

Thanks for posting in the community.

Did my suggestion help you? If you have any concern on this issue,please
post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top