Connecting Tech Pros Worldwide Help | Site Map

Use Custom Class in another Custom Class

  #1  
Old June 30th, 2009, 05:39 PM
Newbie
 
Join Date: Jun 2009
Posts: 4
I am using VB.net with ASP.net 2.0 and am not using Visual Studio. I use my text editor. I have written a class and wrapped it in a namespace called "MyBulb_NS". I want to import and use that namespace in another namespace that i've written called "MyLamp_NS". I have pasted a code snippet below to show how i import the namespace. MyBulb_NS has been compiled to a dll without errors. When I attempt to compile MyLamp_NS it fails. I have pasted its makefile and error below

I am frustrated that it is so difficult to use a custom class in a different custom class. What needs to be done to get this to work? Please help!


Expand|Select|Wrap|Line Numbers
  1. 'Code snipped from MyLamp.vb
  2.  
  3. Option Explicit
  4.  
  5. Imports System
  6. Imports System.Data
  7. Imports System.Data.OleDB
  8. Imports MyBulb_NS
  9.  
  10. Namespace MyLamp_NS
  11.  
  12. Public Class MyLamp
  13. ...
  14.     private bulb as new MyBulb
  15. ...
  16. End Class
  17.  
  18. End Namespace

makeMyLamp.bat
------------------------------------
set indir=c:\www\components\MyLamp.vb
set outdir=c:\www\bin\MyLampVB.dll
set assemblies=System.dll,System.Data.dll,System.XML.d ll

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc. exe /t:library /out:%outdir% %indir% /r:%assemblies%
pause



EError from command line
------------------------------------------------
c:\www\components\MyLamp.vb(7) : warning BC40056: Namesp
ace or type specified in the Imports 'MyBulb_NS' doesn't contain any public
member or cannot be found. Make sure the namespace or the type is defined and c
ontains at least one public member. Make sure the imported element name doesn't
use any aliases.

Imports MyBulb_NS

Last edited by Frinavale; June 30th, 2009 at 09:59 PM. Reason: Added code tags. Please post code in [code] [/code] tags.
  #2  
Old July 1st, 2009, 02:28 PM
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,569

re: Use Custom Class in another Custom Class


I wish I could help you, but I always use Visual Studio.

Is there some reason you can't use VS? There are free editions that could be of great use to you.

http://www.microsoft.com/express/download/
  #3  
Old July 1st, 2009, 02:44 PM
Newbie
 
Join Date: Jun 2009
Posts: 4

re: Use Custom Class in another Custom Class


The project manager does not want to use VS b/c he does not like the generated html that it creates.

Also, I use ubuntu and it is easier to write in my text editor and not bother with loading Windows in Virtual Box

Thanks
  #4  
Old July 1st, 2009, 04:44 PM
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North :)
Posts: 4,940
Provided Answers: 8

re: Use Custom Class in another Custom Class


Quote:
Originally Posted by c4tech View Post
The project manager does not want to use VS b/c he does not like the generated html that it creates.

Also, I use ubuntu and it is easier to write in my text editor and not bother with loading Windows in Virtual Box

Thanks
Then remove the generated HTML...

Wait a second, you're trying to compile a VB.NET application on Ubuntu?!
I'm sorry to tell you this but the .NET Framework is not available in Linux unless you're using something like Mono or Wine...what are you using?
  #5  
Old July 1st, 2009, 04:48 PM
Newbie
 
Join Date: Jun 2009
Posts: 4

re: Use Custom Class in another Custom Class


It's not my decision to remove the generated HTML.

I code using ubuntu, but upload to a Windows server with IIS 6 and ASP.NET 2.0

Thanks
  #6  
Old July 1st, 2009, 04:57 PM
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North :)
Posts: 4,940
Provided Answers: 8

re: Use Custom Class in another Custom Class


Quote:
Originally Posted by c4tech View Post
It's not my decision to remove the generated HTML.
As a developer, you can always chose to remove the HTML generated by Visual Studio.

Visual Studio doesn't really generate a lot of code, it only generates a basic HTML page lay out for you. However, the .NET Server Controls that you use in ASPX pages (like Panel, CheckBox, CheckBoxList, ListBox, GridView, etc) will generate HTML (this is not Visual Studio's fault). Is this what he doesn't like? (because I can completely understand why he wouldn't like this..I too have a particular disgust for what's generated.) In that case you really should be considering a different technology completely. There is MVC ASP.NET that is pretty nice and lets get around the Server Controls...

Anyways, since it's unlikely that you're going to switch technologies at this point, let's take a look at what's going on here.


The first thing that I'd look into is the member definitions for your MyLamp class.

According to what you've posted, it's a public class with private members only. You need some Public Properties or Subs/Functions in order to actually use this class. That's what the compiler's complaining about......
  #7  
Old July 6th, 2009, 03:27 PM
Newbie
 
Join Date: Jun 2009
Posts: 4

re: Use Custom Class in another Custom Class


As it turns out i had to add the following to my makefile in order for /r to know where to find my custom dll's

/libpath:"c:\www\bin"
  #8  
Old July 6th, 2009, 03:40 PM
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North :)
Posts: 4,940
Provided Answers: 8

re: Use Custom Class in another Custom Class


Thanks for sharing the solution :)
Reply