We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Consuming WCF Service in Class Library

Medium Priority
Last Modified: 2013-11-15
Hello All
I have written a WCF service and hosted it on IIS 7.
I am trying to consume it through a c# class library project.
I tried both SVCUtil.exe and 'Add Service Reference' option in VS 2010. But I cannot seem to access the operation in the service.
I get an 'Object Reference' error.

i know for sure the Service works fine because I ran it in Debug Mode in visual studio, and used the test client.

I read in a blog that class library projects cannot read a config file.
So I use a custom channel factory class to read the .config file for the endpoint and binding.
Its through this channel that i try to access the service operation, and thats where I get the error.

Not getting why..

Please help!
Thanks in advance.
namespace Test
    public class Class1 : ProjectEventReceiver
        public override void OnCheckIn(PSLib.PSContextInfo contextInfo, ProjectPostEventArgs e)

        public void StartService(Guid projectUID)
                CustomChannelFactory<ServiceReference1.IService1> channel = new CustomChannelFactory<ServiceReference1.IService1>("WSHttpBinding_IService1", "C:\\Users\\Administrator\\Documents\\Visual Studio 2010\\Projects\\Test\\Test\\app.config");

                ServiceReference1.IService1 svc = channel.CreateChannel();

            catch (Exception ex)


Open in new window

Watch Question

Software Architect
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


Thanks andsSorry for the late response.

That is how i would do it with any application. But in this case, the class library I am developing is an Event Handler to be registered on the Project Server 2010, specifically Project Web Access (PWA). I am new to PWA and Sharepoint customization. Would you know where the config file would be in this case?


The solution was not pertinent to my situation.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.