|
-
Mar 23rd, 2011, 04:21 AM
#1
Thread Starter
Fanatic Member
Cannot Import Namespace I Created
I put this on a file
highlight Code:
Namespace ias
Module robust
<Extension()>
Public Function getChildNode(ByVal node As mshtml.IHTMLDOMNode, ByVal child As Integer) As mshtml.IHTMLDOMNode
Return node.childNodes(child)
End Function
Public hello As Double
End Module
Class SomeClass
End Class
End Namespace
I put this on another file
Got error
Warning 1 Namespace or type specified in the Imports 'ias' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. \\work\c\business\fromwork\currentprojects\program\library\vb.net\angela.vb 5 9 googlepages
What the hell does that suppose to mean?
-
Mar 23rd, 2011, 04:29 AM
#2
Re: Cannot Import Namespace I Created
If you don't specify an access level for classes and modules, I believe that they will be Friend by default. This is an example of why you should ALWAYS provide an access level for EVERYTHING. If you specify what it is then you know what it is. If you accept the default then you have to be sure of what the default is. If you want those types to be Public then declare them Public.
-
Mar 23rd, 2011, 04:59 AM
#3
Thread Starter
Fanatic Member
Re: Cannot Import Namespace I Created
Oh I should put public module rather than just module 
Well I put the wrong sample. But I experimented anyway.
To experiment I create a brand new project and do
vb.net Code:
Imports somename 'This doesn't work Warning 1 Namespace or type specified in the Imports 'somename' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. D:\Documents and Settings\Ferdy\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Module1.vb 1 9 ConsoleApplication1 Imports System.Linq 'works fine. I can import all namespace except my own Namespace SomeName Public Module hello 'It's public here, even though I am sure friends should work just fine Public Sub hello1() End Sub End Module End Namespace Public Module Module1 Sub Main() SomeName.hello1() 'This works End Sub End Module
Same error. I bet I am missing something.
Looks like I simply don't know how to use name space propery
Last edited by teguh123; Mar 23rd, 2011 at 05:36 AM.
-
Mar 23rd, 2011, 05:55 AM
#4
Thread Starter
Fanatic Member
Re: Cannot Import Namespace I Created
Actually I have figured out what the problem is
I should do Imports projectname.somename rather than just imports somename
But that would defeat some important purpose. The same files are in several different projects and I do not want to "know" the project names. I want something that'll work irrelevant of the name of the project is.
Also I want to use imports because I want to create extension. I guess namespace feature is the one that has to go unless some genius will provide me with some solution.
-
Mar 23rd, 2011, 06:09 AM
#5
Re: Cannot Import Namespace I Created
It's not really the project name specifically. Every project has a root namespace. It is set to the project name by default, but you can change it to whatever you like on the Application page of the project properties. Any type that you don't declare within a Namespace block is a member of the root namespace. Any namespace you declare with a Namespace block is a child of the root namespace.
There's nothing to stop you using the same root namespace in multiple projects. If you want types in multiple projects to be members of the same namespace then use the same root namespace in each project and, optionally, the same child namespace(s).
-
Mar 23rd, 2011, 06:20 AM
#6
Thread Starter
Fanatic Member
Re: Cannot Import Namespace I Created
Ah I see. What would really be cool is now that I am on the same namespace anyway, I should be able to do
imports somename
Yes there is no somename namespace
What exist is myrootnamespace.somename
However I do the imports thingy in a file that already is in myrootnamespace.
I guess that doesn't work out isn't it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|