Instantiate Web Service referenced from a DLL from an ASP.NET Web Application

I have created a DLL that has a Web Reference to a Web Service I created, hosted on another server. The idea behind the DLL approach is so that the functionality it provides can be shared across multiple Application Types (Windows & Web).

When I call the DLL from a Windows Application, the Web Service is instantiated from the DLL correctly. When I call the DLL from an ASP.NET Web Application however, an Exception is thrown on the code that Instantiates the Web Service object and the Exception Message is: "The current configuration system does not support user-scoped settings."

While I understand why I am seeing this error, I do not know how to resolve this issue. I do not want to reference the Web Service from the Web Application, it has to be referenced and used from the DLL. Secondly, I would have thought that this error would not have occurred because the reference to the Web Service is made inside the DLL.

The DLL is coded in C# on the .NET Framework 3.5. Any help would be greatly appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EOH_DEVAuthor Commented:

Thank you for your input. This however did not solve my problem. When a reference to a Web Service is added inside a class, it seems to scope the URL as user scoped. (I looked at the class properties by clicking on the "Project" menu item and selecting the properties sub menu, and it showed that the scope was set to Application, but still I got the error. So somewhere it was referencing a user scoped setting.)

Accessing the class from a Windows Application allowed the class to instantiate the Web Service correctly. When I tried to access the class from a Web Application, I got an exception on the line of code that instantiates an object of the Web Service. This was the "The current configuration system does not support user-scoped settings" error.

What I did to solve the error was to select the Web Service in the "Web References" in the solution explorer and view its properties. I then set the URL Behavior to Static. This was set to Dynamic by default. What I then do is I set the URL of the Web Service to a URL that was defined by the user in a settings screen and which I saved in an XML file. So I am basically overriding the static URL at runtime.

This solved the problem. I am not getting the error at all, and the Web Service is now usable from both Web and Windows applications from within the class.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.