views:

854

answers:

3

Hello All, I've just started developing silverlight applications. I've created a webserivce in my asp.net project. Now, when I try to connect to it through my silverlight project I receive the following error:

"the opreation is not supported for a relative uri"

I am using the following url -->

http://192.168.1.2/MyWebsite/SubVersionedHistory.svc

I can find the class and its methods, but I receive this horrific error when I add it.

Thank you for your help and advice,

Vondiplo

A: 

You should be more specific about your problem. For example, are you having this problem when adding the reference or when you actually try to consume the service?

It sounds like you need to be using a full path, including the "http://" but that is just a shot in the dark based on the error message you provide.

[edit]If you are using the built in ASP.NET server instead of IIS then be sure you set a specific port number and use it in your path. For example, I have used http://localhost:4940/MyService.svc for testing[/edit]

John
I receive the error when I try to attach the reference. I am already using the full \ absolute path uri including http.
A: 

Maybe this response can help you

You cannot use AbsolutePath, You need to use AbsoluteURL. Build your URL this way: Uri url = new Uri(App.Current.Host.Source, "../settings.xml");client.DownloadStringAsync(url);

http://silverlight.net/forums/p/28912/95541.aspx

HTH Braulio

Braulio
A: 

I don't think you're alone in hitting this problem. I hit it today with VS2008SP1 + SL2 trying to create a Service Reference for an ADO.NET Data Service. First time I've hit the error.

Others have detailed similar experiences to reach this error:

http://silverlight.net/forums/t/87535.aspx http://silverlight.net/forums/t/56629.aspx

It's not entirely clear at this point if the issue is with the IDE "Add Service Reference" dialog or something specific in the services causing this error. In my case, however, my code still worked despite the error message. I simply passed the URL to my service in the constructor of my DataService proxy client, like this:

var context = new DataServiceContext(new Uri("NorthwindDataService.svc", UriKind.Relative));

Summary point: Just because you hit this error in the IDE, your service reference may still work. Give it a try and let us know if you're seeing errors at run time.

Hope that helps.

[UPDATE] Based on some other advice I've found and tested, you can also try:

  1. deleting your Service Reference
  2. deleting your ServiceReferences.ClientConfig file
  3. saving your solution
  4. and then closing and reopening it in VS.

The simple act of closing and reopening your project has been shown to fix several problems with the Add Service wizard. Re-run the Add Service Ref wizard and you may have better luck. I personally tested this solution on a project today and can confirm it works. Hope that adds extra help to finding your solution.

Todd