• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 918
  • Last Modified:

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.
1 Solution
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.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now