开发者

App.Config not being read

I am trying to test a class in Service handler using NUnit project. My service handler class is part of a class library project which gets data from a WCF service. When call from test project method comes into service handler class and a method in that class tries to creat clients object with statement - using (Client client = new Client()), it throws exception : "Could not find default endpoint element that r开发者_如何学Pythoneferences contract 'XYZ' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

Loos like my app.config file is not being read in this case, thats why this exception is coming. has anybody ever faced this issue? I need urgent help regarding this.


Add an App.Config to your NUnit assembly. Add the WCF service client config to the App.Config and it should work.


Rename app.config to the namespace of the Nunit Assembly that contains your tests, for example;

Namespace.Project.Class.config

namespace Namespace.Project.Class
{
    [TestFixture]
    public class Imports
    {
        [Test]
        public void InsertFile()
        {
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜