Results 1 to 7 of 7

Thread: adding class in vs.net asp.net project

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    UK
    Posts
    164

    adding class in vs.net asp.net project

    Hi,
    I have some code that I want to use in an existing vs.net project. I add a class in the IDE and paste the code into into it.
    Else where in the project I use this class. I import the namespace it is contained in and intellisense recognises the various member variables and functions within it. However when I run the project (an asp.net application) I get the errormessage "Type 'myClass' is not defined".

    Do I have to create a new dll project thing, compile the class and add it to the bin directory or should the class be automatically compiled into the project dll?

    Also when I make changes to the class code will it automatically recognise these when the project is recompiled?

    Thanks,

    Alex
    ASP, SQL, VB6, Java Script and dubious guitar playing skills.

  2. #2
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97
    add a class library to your existing project
    then build your class within the library
    add a reference in your original project to your class library
    then you should be able to declare your class from within the original project

    hope that helps

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    UK
    Posts
    164
    Do I create a new class library project put my code in then add this to the solution? I only have an option to add a class file not a class library when I am within the existing solution. It docent seem to compile this class into a seperate dll that I can reference?

    Alex
    ASP, SQL, VB6, Java Script and dubious guitar playing skills.

  4. #4
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97
    click right on your solution file it should say add project

    click this option then add a class library

    then click right on the new project that's been added and select add item from this menu you should be able to add your class

  5. #5
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97
    oh n u don't need to reference n e dll's just goto your other project where the references are and right click, select add new reference

    then you should be presented with another screen along the top of this screen there should be a 'projects' tab click this and select your class library from the list and click ok

    then to reference your library you need to use its name ie.

    Dim MyObject as New MyLibrary.MyClass

    hope thiis helps

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    UK
    Posts
    164
    Thanks Optimus for your help.
    The problem seemed to be that I had some errors in my project that the compiler seemed to skip when I was working on seperate aspx files. However when I added a seperate class file these errors caused the compiler to not recompile the projects dll hence the error.

    Adding the classes your way was successful as the dll was seperate from the main project.

    Thanks,

    Alex
    ASP, SQL, VB6, Java Script and dubious guitar playing skills.

  7. #7
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97
    no probs glad i could help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width