WPF for WCF Resolution

I have created a WPF browser application that I want to connect to a WCF service. The service is in the same solution as the WPF application. This is the default service that Visual Studio creates using the GetData (int) method

I am trying to call this service with the following code:

var client = new Service1.Service1Client();
client.GetData(10);

      

The given line shows the following error (client.GetData (10);)

{"Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}

      

Please, help

+1


a source to share


2 answers


This solution from Scott Lanford worked for me:
http://www.codeexperiment.com/post/Debugging-XBAPWCF-Applications.aspx

Quote: The
possible reasons for this error are numerous, but in this case it was because the default Debug-> Start Action for an XBAP project is Launch Browser at URL, where the URL simply points to the .xbap file on disk (for example C: \ projects \ MyProject \ Bin \ Debug \ myproject.xbap).

For an XBAP application to partially trust to communicate with a WCF service, it must be deployed from the same domain and port as the WCF service. The way to work around this issue is to spoof the XBAP URL by launching the XBAP application with PresentationHost.exe and submitting the XBAP URL (copied from the Launch Browser with URL value) using the debug option and the WCF service URL through debugSecurityZoneURL parameter.



For example, the debug options for your XBAP project should look something like this:

Start Action -> Run External Program =% windir% \ system32 \ PresentationHost.exe

Launch Options -> Command Line Arguments = -debug "c: \ projects \ myproject \ bin \ debug \ MyProject.xbap" -debugSecurityZoneUrl " http: // localhost: 2022 "

+3


a source


You need to configure the client access policy on the server. Running in a browser comes with a number of security restrictions.



I think this article should provide you with the information you need, http://www.dotnetcurry.com/ShowArticle.aspx?ID=208&AspxAutoDetectCookieSupport=1 .

0


a source







All Articles