In have a WinForms application which, recently, has started to show a design-time error when opening some forms:
Could not find default endpoint element that references contract ...
You can see the winforms designer screenshot here.
It's a well-documented problem (here, here and here for example), except that my problem has only appeared since I have tried to introduce dependency injection.
I have a business layer object calling this webservice. I have changed some methods like such:
public class Stocks : BusinessObjectBase
{
private readonly IAxReferenceService axService;
private readonly IDALStock dalstock;
public Stocks()
{
this.axService = new AxReferenceServiceClient();
this.dalstock = new DALStock();
}
public Stocks(IAxReferenceService axService, IDALStock dalStock)
{
this.axService = axService;
this.dalstock = dalStock;
}
public IEnumerable<Model.Stock> GetStock() {
return this.axService.GetStock();
}
}
When I remove my dependency injection for this service, it suddenly all works:
public class Stocks : BusinessObjectBase
{
private readonly IDALStock dalstock;
public Stocks()
{
this.dalstock = new DALStock();
}
public Stocks(IDALStock dalStock)
{
this.dalstock = dalStock;
}
public IEnumerable<Model.Stock> GetStock() {
using (var axService = new AxReferenceServiceClient()) {
return axService.GetStock();
}
}
}
My webservice is configured like this (and yes, it's both in the business layer project and the main project):
<binding name="BasicHttpBinding_IAxReferenceService"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
...
<endpoint address="http://.../AxReferenceService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IAxReferenceService"
contract="AX.IAxReferenceService"
name="BasicHttpBinding_IAxReferenceService" />
What is the problem I introduced with my injection?