Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Creating Asp.Net 2.0 DLL

  • 09-02-2006 10:32am
    #1
    Closed Accounts Posts: 216 ✭✭


    Hi,

    I am currenly designing an Asp.net 2.0 website and am looking to create a dll of all my connection strings. I am, however, using Visual Web Developer 2005 Express Edition, and I cant seem to find a way to compile a dll. Is there any external program that would help me in this?

    Cheers
    gogul.


Comments

  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I'm not really sure what you mean by "dll of all my connection strings", with ASP.Net 2, you're creating a website, not a traditional application so compiling to a dll isn't really something you'd do. If you really really want to do it that way, you would create a seperate class library project to your website (you may not be able to do this in Visual Web Dev, you may need to get one of the Visual Studio Express versions), you could put your connection strings in a class as constants, then build that project to a dll and reference it from your Web project.

    In general the recommended way to store connection strings is through the web.config file (or possibly machine.config if they're to be shared amongst different sites on the same machine). Add something like
    <appSettings>
    		<add key="ConnectionString" value="Server=servername;User ID=username;Database=mydb;Password=pwd;Persist Security Info=True"/>
    	</appSettings>
    

    under <configuration>, you can then access it in your code using System.Configuration.ConfigurationManager.AppSettings("ConnectionString"). Much easier and neater than a dll, and if you deploy to a different machine, or your connection strings need to change, you just edit the web.config file in any text editor.


  • Closed Accounts Posts: 216 ✭✭gogul


    Estentially, I'm building a class that will connect and return a recordset simply by initialising and passing in the necessary parameters (IP, DB, user, pass, SP, etc). I want this in a dll so that any page that wishes to get a RS just needs to import the dll and create an instance of that class.

    It's not necessary, but I felt it might be benefically in the long run as I have recently looked back at some of my ASP pages and found several different connection functions, which is a bit of a headache.

    I have been unable to find any way to do this through Express Edition, so I'm just looking for some 3rd-party app that may help

    gogul


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    Ah, I see what you mean now. What you're talking about is commonly called a data layer or data tier, there's a good explanation of it here if you're interested (but that probably goes into much more detail than you're interested in).

    As above what you'll need to do is create a class library project seperate to your web site project. You then put you're classes for accessing data into that. If Visual Web Dev doesn't let you do this, I'm pretty sure one of the VS 2005 Express Editions will (they're free). You should then be able to either reference the project directly from your web project, or buy building it to a dll and referencing that.


  • Closed Accounts Posts: 216 ✭✭gogul


    Thanks stevenmu,

    I'll have a look into that

    gogul.


  • Closed Accounts Posts: 140 ✭✭Sneaky_Russian


    with regard to finding your dll,

    i can't speak about the express editions but in VS 2005,
    You first publish the website (right click project, publish website), then you can access the DLL in the location you published the website to.


  • Advertisement
  • Closed Accounts Posts: 216 ✭✭gogul


    I got it sorted. I downloaded MS C# 2005 Express Edition, and in the New Project option, you can select Class Library. Once I compiled the dll, I just moved it into the Bin folder and was able to import it without hassle into my website.

    Cheers for all the help

    gogul.


Advertisement