Avatar of CoreSupport
CoreSupportFlag for United Kingdom of Great Britain and Northern Ireland asked on

linking a objectdatasource to a class in a DLL

Hi All,
I have a Visual Studio 2005 c# web project and an existing class lilbrary from another application. Some of the classes in the DLL are to be used in the web app.
I was thinking of using an ObjectDataSource to link to a classes method in DLL but all the information I m finding suggests I have to put the classes in the APP_CODE folder to access it in the ObjectDataSource smart tag.
Is there any way to link to DLL's which are included as references in you project?
Thanks
ASP.NET

Avatar of undefined
Last Comment
CoreSupport

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
NazoUK

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
CoreSupport

Thanks NazoUK!! That worked when i tried it again! odd that i couldnt see it before.
Brilliant.

On a totally different issue, if your using a object datasource with a method in a DLL that querys a database, is there an easy way to specify the database connection string for the method. Since the method is in a DLL and normally we would just pass the string.
However, the object data source parameters wont let you use Application state. So im not quite sure how to get the connection string to the method?

I ve seen one example where they use the WebConfigurationManager, but all these examples are where the class is in the App_Code folder.
No worries if you've no idea. Just thought id ask.
Thanks
SOLUTION
NazoUK

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
CoreSupport

Hi there,
you actually covered all the questions I had! I was storing the connection string in web.config and wanting to pass it to my DLL using the ObjectDataSource.

To get the connection string in a DLL:
1) Add the System.Web.dll
2) Add the System.Configuration.dll (for some reason the classes you need are in here instead of the default one)
3) you can then access WebConfigurationManager.ConnectionStrings

This isnt great though as if you've more than one connection string your going to have to hardcode its name in your DLL.

I ended up going with the selectParameters option! :)
much neater
Thanks so much!
great answer.
D


ASKER
CoreSupport

Thanks so much! Was thinking there must be better ways of using the ObjectDataSource. youve helped me out alot there.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes