VS.net 2003 and ASP.net DLL prob

Status
Not open for further replies.

developer

Baseband Member
Messages
88
I have been developing ASP.net in Dreamweaver. I used to use normal <script runat="Server"> but now i want to shift to code behind. A normal option is to make a Web App project in VS.net 2003. But i wanted to make my classes seperately so that i coud use them in other projects and places too.

So i made a class library and then started compiling it. I built the project and picked it up from the projects bin folder and placed it in my bin folder in IIS. I tried using the classes but cudnt. But later i compiled a VB file from the same project via the command line (vbc) and placed it in my bin folder, it worked.

Please help me as i dnt know what to do.
 
that dll you made with the functions and such, you can call those functions and classes from any othe asp.net application. So here's what you do:
1. Create that dll
2. start a new solution or project (asp.net project)
3. add a reference to your .dll via the "Add a Reference" dialog.
4. add a using directive if needed
5. use the objects like normal
6. build the web application.
 
Adding a reference is if i am making my web app in VS. But i am doing it in Dreamweaver. If i placed the dll in my bin folder and then imported the namespace shouldnt it work?


Eg i Create a Class Library Projecy named ABC

I create a file named MyTestClass.vb

Namespace MySpace

Public Class MyTestClass
Public Function ShowString() As String
Dim someString As String
someString="abc"
Return someString
End Function
End Class

End Namespace


I then build this. I go to the folder where i had placed the class library and then pick up the dll from the bin folder. I copy it to the bin foder of my site in wwwroot.

Then i create a page (in Dreamweaver or Notepad). it imports the namespace and tries to create an object instance of the class.

Is there something wrong? Somehow i cant create a object of the class. I import the namespace etc. Is there something else i need to do?
 
Then you need to add a reference using the command line compiler options. I'm not sure what they are, but you could look that up since it's easy.

edit use this: (replace csc with whatever the vb.net compiler is)
Code:
csc /lib:<path_to_dll> /reference:<dll_name> <source_file_to_compile>
 
Thanks a Lot. The problem was solved for VS when i added a reference as you said.

But as i said earlier that if i manually used command line for compiling the source file and then placing the dll in the bin folder of my web app, i can easily use the classes. The problem comes when i build the project in VS and then copy that dll.

Actually if i have

vbc /t:library MyTestClass.vb

it works. But even in this sometimes its gives an error in many imports and cannot import those namespaces.

Like a vb file containing something like

Imports System.Xml

gives an error when compiled via the above command line directive. I tried adding a reference to those dll but failed to do so.
But thanks a great deal. You did solve a big problem.
 
Status
Not open for further replies.
Back
Top Bottom