Skip to main content

Microsoft Silverlight

Answered Question SL2B2 WCF Web Services ErrorRSS Feed

(0)

digitalml
digitalml

Member

Member

34 points

25 Posts

SL2B2 WCF Web Services Error

This worked fine in beta 1, and now when i add a reference to web service in beta 2 and instantiate a new instance of that service i get this error the runtime

"Could not find default endpoint element that references contract 'Namespaces.IEgmWebManager' 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."

Everything is the same as it has been since beta 1. The end points all look good in the ServiceReferences.ClientConfig file which as I understand it is now used.

If you have any ideas please let me know.

Thanks
DML

 

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: SL2B2 WCF Web Services Error

Read this thread. Have you updated your clientaccesspolicy file if you are doing cross-domain call?

 http://silverlight.net/forums/t/17733.aspx

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

digitalml
digitalml

Member

Member

34 points

25 Posts

Re: Re: SL2B2 WCF Web Services Error

Yes, the clientaccesspolicy.xml and crossdomain.xml are updated and in the root as they should be, but this is not the problem... The error happens right when I instantiate a new instance of the webservice, eg: MyWebService ws = new MyWebService();

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Re: SL2B2 WCF Web Services Error

 Then it's a different problem. Can you add Service Reference or you have not tried that? Try to add Service Reference and report back. You might have another install problem.

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

digitalml
digitalml

Member

Member

34 points

25 Posts

Re: Re: Re: SL2B2 WCF Web Services Error

Already dealt with the service reference add problem a few days back, reinstalled and I can add service references fine now.  This only happens at runtime when the service is instantiated. Any other ideas?  :)

Thanks
DML

 

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Re: Re: SL2B2 WCF Web Services Error

Then check your ServiceReferences.ClientConfig, see if you have more than one end points defined for this service. I have seen this problem, more than one end point being added in the ClientConfig. Use WCF Service Configuration Editor to do any editing on the ServiceReferences.ClientConfig file. Make sure the url in end point is valid. Binding is correct.

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

digitalml
digitalml

Member

Member

34 points

25 Posts

Re: Re: Re: Re: SL2B2 WCF Web Services Error

Here is my ServiceReferences.Client.Config file, everything looks good to me...

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="egmWebManager" maxBufferSize="65536" maxReceivedMessageSize="65536">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://10.128.106.92/egmwebmanager" binding="basicHttpBinding"
                bindingConfiguration="egmWebManager" contract="Namespaces.IEgmWebManager"
                name="egmWebManager" />
        </client>
    </system.serviceModel>
</configuration>

digitalml
digitalml

Member

Member

34 points

25 Posts

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

Sorry no extra period is in the ServiceReferences.ClientConfig file name it was a typo...

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Re: Re: Re: SL2B2 WCF Web Services Error

I don't see anything wrong.

the "Namespaces" in contract should be the real namespace of your WCF, right?

contract="Namespaces.IEgmWebManager" ,

Can you put Try/Catch to see what is in the Exception?

OK I looked at your error message again. Is "Namespaces.IEgmWebManager"

Is your WCF namespace really called  "Namespaces" ? Maybe that is the problem.  Give it a real namespace. "Namespaces" could be a key word in .Net.

 



 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

digitalml
digitalml

Member

Member

34 points

25 Posts

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

Yes, "Namespaces" is simply a placeholder I have added to these posts as I'd prefer not to list my actual namespaces. The error I posted in the orginal post is the error from the try catch and has no inner exception information.

"Could not find default endpoint element that references contract 'Namespaces.IEgmWebManager' 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."

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

 You can try to remove your Service Reference and re-add them back.

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

ptangyangkipperbang
ptangyan...

Member

Member

14 points

2 Posts

Answered Question

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

In SL2B1 this worked:-

Dim service1 As New myWebService.MyWebServiceSoapClient()

The auto-generated Reference.vb in SL2B2 no longer applies default values for binding and endpoint address when calling New() with no parameters.

So, something like this is now required:-

Dim service1 As New myWebService.MyWebServiceSoapClient(New System.ServiceModel.BasicHttpBinding, New System.ServiceModel.EndpointAddress("http://TheFullEndPointAddressOfYourService"))

Hope this helps.

 - qfwp

digitalml
digitalml

Member

Member

34 points

25 Posts

Answered Question

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

So even though the above answer relates to visual basic and I'm using c# it got me thinking about the way I am loading my xap's. 

We are using a module based type architecture and load xap's dynamically through a WebClient call and LoadAssemblyFromXap(). Each xap has its own web service reference and thus its own ServiceReferences.ClientConfig file. Well since beta 1 didn't use this file at all I never considered it a problem. Now that beta 2 uses the ServiceReferences.ClientConfig file it made sense to me that as long as each xap had this file the service references would be fine. That's where my misconception was... Turns out that the Silverlight application (xap) that loaded the other xap's via LoadAssemblyFromXap() must have the endpoints that the other xap's use defined in its ServiceReferences.ClientConfig file as well.

While this makes sense it also seems a bit off to me... What this essentially means is that my main Silverlight application must always know about any web service references inside of any other xap's I load dynamically, which doesn't make for a very good module / plug n play approach.

So whats the answer? I could do as the above post suggests and hard code / supply the constructor of the service with the end point information but again that defeats the whole power of the config file. What I've ended up doing is reading the config file manually from the xap I've loaded throwing that into some variables and then supplying that to the constructor of the service references in the dynamically loaded xap's so that my main Silverlight application's ServiceReferences.ClientConfig file never needs to know about them and I can still maintain the dynamic plug n play architecture I've built.

Like i said earlier, while this makes sense to me, it also feels a bit off. Is there a better way to load xap's dynamically?  I expected that each xap would refer to the ServiceReferences.ClientConfig file embedded within it rather than look for it where LoadAssemblyFromXap() was called from. Perhaps someone from Microsoft could please explain the architecture behind this?

Thanks for everyone's help...
DML

 

phillipi
phillipi

Member

Member

6 points

7 Posts

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

This is a great post. I was just going to pull out my hair for a simple HelloWorld app that utilizes WCF proxy to get a response from the server. The WCF Silverlight Tutorial on this website shows for the former implementation and is apparently now outdated. 
 
Phillip

zenuke
zenuke

Member

Member

50 points

61 Posts

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

can you explain what you mean by the fullendpointaddressofyuorservice??

ptangyangkipperbang
ptangyan...

Member

Member

14 points

2 Posts

Re: Re: Re: Re: Re: SL2B2 WCF Web Services Error

 It's the URL of your web service. 

 In my current project, for example, it's http://localhost:1955/svcMain.asmx

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities