1

I'm getting the error mentioned in the title and not sure what exactly I may be doing wrong. I'm running Mono 2.10.6 on openSUSE. The issue only happens when I try to browse to the WCF service (web pages load fine).

Service code is:

namespace CyberLane
{
    [ServiceContract]
    public class DataServices// : IDataServices
    {
        [OperationContract]
        public TweetDTO[] GetLatestTweets()
        {
            return MasterRepository.GetTweets().Select(x => new TweetDTO(x)).ToArray();
        }
    }
}

my Web.config has the following:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="CyberLane.DataServicesAspNetAjaxBehavior">
                 <enableWebScript />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
        <service name="CyberLane.DataServices">
            <endpoint address="" behaviorConfiguration="CyberLane.DataServicesAspNetAjaxBehavior" binding="webHttpBinding" contract="CyberLane.DataServices" />
        </service>
    </services>
</system.serviceModel>

Please ask me if you need more information, and I'll be more than happy to share! This has been driving me crazy for a couple weeks now.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
JustinN
  • 896
  • 1
  • 14
  • 28

1 Answers1

1

First, the best practice and common approach is to decorate IDataServices (interface) with ServiceModel attributes, not a class implementing it.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
  • I originally had it that way, but was getting this error "Contract 'CyberLane.IDataServices' was not found in the implemented contracts in this service host" so I tried it without an interface and get the same error. – JustinN Apr 07 '12 at 09:44
  • @JustinN: I recommend to rollback, I mean use interface. That will avoid additional questions. Also make sure that you type correctly, WCF is case-sensitive everywhere. – abatishchev Apr 07 '12 at 09:45
  • I have rolled back and I still get an error. Do I need to do something else to allow it to recognise the interface as a contract other than the atttribute? – JustinN Apr 07 '12 at 09:49
  • @JustinN: Is the WCF assembly external to the Web Application? If yes - have you referenced it? To make sure it's loaded at the moment of contract activation. – abatishchev Apr 07 '12 at 09:53
  • it is all inside the same project. – JustinN Apr 07 '12 at 10:00
  • @JustinN: Have you tried top create an empty web app project, add a wcf project, and start? Another way - create it under Windows, make sure it works, and open under Suse then (if you have Windows). – abatishchev Apr 07 '12 at 10:33
  • Just tried a brand new WCF service which works in Windows, and it gives the same error on OpenSUSE. I am now thinking perhaps Mono has a bug, rather than my code/config having a problem. – JustinN Apr 08 '12 at 09:55
  • @JustinN: Sounds reasonable. Unfortunately( But out of curiosity - what markup does have your .svc file? – abatishchev Apr 08 '12 at 10:10
  • @JustinN: And what version of Mono do you use? And how do you install/run your WCF service, just as a regular web app using XSP? – abatishchev Apr 08 '12 at 10:11
  • I tried with a brand new WCF service from Visual Studio, with the default code. That gave the same error, and I have asked on the Mono IRC channels, who have confirmed that the current version of Mono breaks WCF in Mod_Mono. So it seems unfortunately, my code was not at fault, it was a bug in the mono framework. The fix for the code is in GitHub, when I compile and run that code, it seems to work. Thank you for all your help :) – JustinN Apr 09 '12 at 11:07
  • Glad to help! It was interesting for me as well. Seems nothing to accept, but you still can upvote somewhere else :)) – abatishchev Apr 09 '12 at 11:46