Answered by:
creating namespace

Question
-
User-1474096950 posted
Imports one
i tried to create a namespace but its giving error
Warning 5 Namespace or type specified in the Imports 'one' 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.
i opened a new class file ie class1.vb
in that i cretaed
namespace
onePublic
Class Class1Public
Console.WriteLine(
Function MyMethod()"Adding Inventory via MyMethod!")End
End
end
Function Class namespaceWednesday, January 27, 2010 4:27 AM
Answers
-
User-952121411 posted
no the Intellisense did nto show the 'One' namespaceCan you scroll through the namepsapces and see any other project namespace or class name that is required?
or let me know step by step things fr creating a namespace a7 calling it in the pageUsually at this point I recommend the following: since it appears you are pretty new to .NET, I recommend creating a brand new project and using the tested code I provided in my earlier post and get that working. At least this way you can see how namespaces work, and how it does work properly. Then once you get it working, then you can go back to your existing project and determine the issue. Based on your brief descriptions, I do not know the exact issue. If you want you can post all of the code, but I still think using the test code I provided to get things working is a better option.
For some more information on using Namespaces in VB.NET, take a look at the following information:
Managing Namespaces in VB.Net:
http://www.fmsinc.com/free/NewTips/net/nettip40.asp
Understanding and using Namespaces in VB.NET:
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, January 29, 2010 2:30 PM
All replies
-
User527778624 posted
HI
u have written one function which doesn't returns any value.
so replace that function with this sub procedure, and check.
----------------------------
Public Sub MyMethod()
Console.WriteLine("Adding Inventory via MyMethod!")
End sub
---------------
also check that it doesn't hav any errors.
--------------
Happy Coding.
Mark as Answer if it helps.Wednesday, January 27, 2010 6:00 AM -
User-1474096950 posted
i used the same but still giving same error msg on import statement
Wednesday, January 27, 2010 6:58 AM -
User-952121411 posted
What might be happening is that in order to import a namespace, it needs to be the fully qualified namespace including the application namespace in order to be recognized. Use the Intellisense in VS.NET to help with finding the namespace. The following code sample does work without error:
1st, the class:
Namespace One Public Class Class1 Public Function MyFunction() As String Return "Adding Inventory via MyMethod!" End Function End Class End Namespace
And 2nd, a sample .aspx with an Imports to that namespace 'One' fully qualified starting with the application name:'Imports the Namespace 'One' Imports MyInventoryAppName.One Partial Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub End Class
Hope this helps!Wednesday, January 27, 2010 9:40 AM -
User-1474096950 posted
i used the same but still the same error
my application name is project1
so i wrote
imports project1.One
but same error
is any path to be mentioned
as my this class file is in app_code\vb\cl\class1.vb
Thursday, January 28, 2010 12:50 AM -
User-952121411 posted
imports project1.OneWhen you typed 'project1.' did the Intellisense show the 'One' namespace, or did you just manually type that line? If it did not show it, then use Intellisense to drill down to the proper namespace, and do not try and guess it.
Also, these assumtions are made in that your class file is in the same project in which you are referencing it from (by metioning it is in the app_code folder). If this class is part of a separate project and compiled on its own into a .dll, you need to add a reference to it from the 'Project References' before you will be able to use it.
Thursday, January 28, 2010 9:20 AM -
User-1474096950 posted
no the Intellisense did nto show the 'One' namespace
the class file is in the same project in which its called
or let me knw step by step things fr creating a namespace a7 calling it in the page
Friday, January 29, 2010 2:09 AM -
User-952121411 posted
no the Intellisense did nto show the 'One' namespaceCan you scroll through the namepsapces and see any other project namespace or class name that is required?
or let me know step by step things fr creating a namespace a7 calling it in the pageUsually at this point I recommend the following: since it appears you are pretty new to .NET, I recommend creating a brand new project and using the tested code I provided in my earlier post and get that working. At least this way you can see how namespaces work, and how it does work properly. Then once you get it working, then you can go back to your existing project and determine the issue. Based on your brief descriptions, I do not know the exact issue. If you want you can post all of the code, but I still think using the test code I provided to get things working is a better option.
For some more information on using Namespaces in VB.NET, take a look at the following information:
Managing Namespaces in VB.Net:
http://www.fmsinc.com/free/NewTips/net/nettip40.asp
Understanding and using Namespaces in VB.NET:
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, January 29, 2010 2:30 PM