0

I have a Silverlight application that is running perfectly in my local machine, consuming WCF services form a development server (self-hosted in windows services).

I have to debug one of the WCF services, in order to find the root cause of a bug. I added my debug/tracing info in the service, and installed in a virtual machine (and even locally), but since then, I get the well-known cross-domain error:

"An error occurred while trying to make a request to URI 'http://MyVMMachine:4096/MyService'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details."

That's strange, because if consuming from a dev server, it works fine, but if installing the service in a dev machine, or even locally (self-hosted in windows service as well), it doesn't work.

Here is the service original code:

public partial class WindowsService : ServiceBase
{
    ServiceHost _Host;

    public WindowsService()
    {
        try
        {
            InitializeComponent();
        }
        catch (Exception exc)
        {
            Server.One.Log("Windows service initialization failed: " + exc.Message);
        }
    }

    protected override void OnStart(string[] args)
    {
        try
        {
            Server.One.Start();
            _Host = new ServiceHost(typeof(Service));
            _Host.Open();
        }
        catch (Exception exc)
        {
            Server.One.Log("Windows service start failed: " + exc.Message);
        }
    }

    protected override void OnStop()
    {
        try
        {
            if (_Host != null)
                _Host.Close();
            Server.One.Stop();
        }
        catch (Exception exc)
        {
            Server.One.Log("Windows service stop failed: " + exc.Message);
        }
    }
}

After reading Carlos Figueira's article on this subject, I changed the service applying his approach, but still not working.

Any ideas???

Thanks!

Roberto
  • 645
  • 1
  • 8
  • 16

1 Answers1

0

Try with fiddler to see where is your application really asking for your service.

This has happened to me a couple of times and it usually was because of server port changes 8-)

Just change your ServiceReferences.ClientConfig to the server port.

Take a look at your Service project configuration (web tab) and set the specific port as 4096 if you want to call it there:

enter image description here

zapico
  • 2,396
  • 1
  • 21
  • 45
  • Hey. I already did (I should have posted that). The app is requesting both files. Result 400 for clientaccesspolicy.xml and crossdomain.xml files. I have both there, but because this is a self-hosted, I don't think it is able to get it. – Roberto Aug 29 '12 at 14:52
  • Thanks for your help. I did already change the clientconfig to the right server/port. About the web tab, since this is a windows service, I don't think that I would have one in the service side. – Roberto Aug 29 '12 at 15:06
  • Ouch, I didn't realize it wasn't a web project xD – zapico Aug 29 '12 at 15:19
  • If you already did it you should post an answer for next visitors ;-) – zapico Aug 29 '12 at 15:21