Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » VS.net 2003 and ASP.net DLL prob
Closed Thread
Old 07-15-2005, 03:11 PM   #1 (permalink)
 
Junior Techie

Join Date: Dec 2004

Posts: 88

developer

Default VS.net 2003 and ASP.net DLL prob

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.
__________________
Somewhere I Belong...
developer is offline  
Old 07-15-2005, 03:48 PM   #2 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

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.
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 07-15-2005, 04:03 PM   #3 (permalink)
 
Junior Techie

Join Date: Dec 2004

Posts: 88

developer

Default

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?
__________________
Somewhere I Belong...
developer is offline  
Old 07-15-2005, 04:47 PM   #4 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

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>

__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 07-15-2005, 05:10 PM   #5 (permalink)
 
Junior Techie

Join Date: Dec 2004

Posts: 88

developer

Default

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.
__________________
Somewhere I Belong...
developer is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On