I am trying to create a common service library shared between a WCF web service and a local data service. However, when trying to utilize the service by clicking on
Project -> Add Service Reference
and then trying to use the base interface instead of the proxy interface I get a cast error with the following code:
IMyService _context = (IMyService)new ServiceReference.MyService();
Here is a layout of the projects / classes:
Common Library Project
[ServiceContract]
public interface IMyService
{
[OperationContract]
void DoWork();
}
Web Service Project
public partial class MyService : IMyService
{
public void DoWork()
{
//DO STUFF
}
}
Client Project
IMyService _context = (IMyService)new ServiceReference.MyService();
runtime error thrown: Can't cast object.
IMyService _context = new ServiceReference.MyService();
compile time error thrown: Explicit cast is missing.
(note that Client Project references Common Library Project)