Skip to main content
Home Forums Silverlight Programming Visual Studio & Silverlight Development Tools Can't display SQL Server table data after published the silverlight app
12 replies. Latest Post by Tracy Au on July 30, 2008.
(0)
Tracy Au
Member
5 points
26 Posts
07-22-2008 6:46 PM |
HI, my app is developed with silverlight 2. It works well with studio 2008. After published this application, it is fine to show the page , but can't display any data retrieved from SQL server. My data connection string is like: Data Source=10.80.8.90; Initial Catalog=RPT_SYS;Persist Security Info=True;User ID=user;Password=test. The data operation is based on WCF service. Anyidea? Thanks in advance.
Shaji-mji
Participant
1129 points
260 Posts
07-23-2008 1:54 AM |
Please check the URI of the WCF Service that is mapped... It will have the temp URI which is the problem.
07-23-2008 8:21 PM |
I took your advice and following the guide in http://silverlight.net/forums/t/19021.aspx to add the code into my .cs files,
ServiceReference1.
Unfortunately it is the same problem .
Here is the error:
[Arg_TargetInvocationException]
Arguments:
Debugging resource string are unavaliable. Often the key and arguments provide sufficient infomation to diagnose the problem
Allen Ch...
Star
13662 points
1,780 Posts
07-23-2008 10:34 PM |
Hi
Tracy Au:My data connection string is like: Data Source=10.80.8.90;
Did you publish WCF service on the same machine? If not please check whether the IP is correct. I believe it's a private IP address and may not work if your project is moved to another machine.
You can create a test project on that machine to query the database. If it can work the connection issue can be excluded.
07-24-2008 12:28 AM |
the IP is a static IP. I also try to create a test project on that machine. Similar as the previouse application, it works well with studio.net, but not working for the real URL
07-24-2008 1:24 AM |
What does the private IP mean:
http://en.wikipedia.org/wiki/Network_address_translation
quote: In a typical configuration, a local network uses one of the designated "private" IP address subnets (the RFC 1918 Private Network Addresses are 192.168.x.x, 172.16.x.x through 172.31.x.x, and 10.x.x.x (or using CIDR notation, 192.168/16, 172.16/12, and 10/8), and a router on that network has a private address (such as 192.168.0.1) in that address space.
Such IP addresses cannot be understand correctly on other machines that belongs to other networks. What I suggested is to check whether your server (since your're querying database via WCF, the server machine is where the WCF service resides) can understand that IP and query database successfully by creating and run a test application on server (don't create Silverlight application, instead, you can simply create a Console application or WinForm application to test). In this way we can also test whether the access from your server is denied by the firewall of the machine where the database resides. Of course, if the develop machine and the server machine are the same one we can exclude these possibilities directly.
Please test it and tell us the result.
07-24-2008 6:27 PM |
Thanks for your explanation. I tested a new Winform application on the same server, it works. My silverlight application currently works after manually change the endpoint address from both ServiceReferences.ClientConfig and web Config files. So it is clear that the problem is from how to map the URI of the WCF. But I am still confused why my application doesn't work as I have added the code to map the URI of WCF automatically. During the implementation, I also try to output the dynamic address of WCF, it is exactly same as what I changed from config files manually.
07-24-2008 9:01 PM |
To test whether it's the endpoint issue you can try to hard code the endpoint address when initializing the proxy:
EndpointAddress endpoint = new EndpointAddress("uri"); Binding binding = new BasicHttpBinding(); ServiceReference1.Service1Client proxy = new SilverlightApplication26.ServiceReference1.Service1Client(binding, endpoint);
Please test it to see if it works.
In addition, could you give us the details about that exception? Can you post the call stack?
07-27-2008 6:25 PM |
Here is the code I used to map the URI of WCF service.
ServiceReference1.BTSServiceClient client = new BTSDataCleaning_07_07_.ServiceReference1.BTSServiceClient(new System.ServiceModel.BasicHttpBinding(), new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../BTSService.svc")));
There are two results after adding the code into the file:
1, not change the endpoint address from both servicereferences.clientconfig and web configfiles, and keep them with the default values:
endpoint address="http://localhost: 3365/BTS_ApplicationWeb/BTSService.svc" binding="basicHttpBinding" contract="BTS_ApplicationWeb.IBTSService" bindingConfiguration="maxBinding" >
The system shows the error message:
Additional information: [UnexpectedHttpResponseCode]Arguments:Not FoundDebugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=UnexpectedHttpResponseCode
2. Application works fine if I manually change the endpoint address from both config files
endpoint address="http://10.80.XX.XX/BTS_ApplicationWeb/BTSService.svc" binding="basicHttpBinding" contract="BTS_ApplicationWeb.IBTSService" bindingConfiguration="maxBinding" >
07-28-2008 3:00 AM |
Did you set the absolute value for the endpoint address in Web.config? If so it need to be changed after deployment otherwise server cannot find the correct endpoint.
Tracy Au:Theoretically, I think the operation in results 2 shouldn't be happened, because I have already add the code into the file to map the URI for the service automatically. But it looks not working. How to fig it out?
I think what you did is to hard code the endpoint address at client side. This will specify where the message should be sent. But when server receives the message it cannot find the endpoint due to the incorrect endpoint address set in Web.config.
07-29-2008 7:58 PM |
Would you please tell me how to map the URI of wcf service automatically? Because it is not practice that I need to change the endponit address from webconfig file manually if I changed the server everytime
07-29-2008 9:39 PM |
The better option is to set relative endpoint address in IIS hosting scenario. Please check out this article for more details:
http://msdn.microsoft.com/en-us/library/ms733749.aspx
Quote:
When hosting with IIS, you do not manage the ServiceHost instance yourself. The base address is always the address specified in the .svc file for the service when hosting in IIS. So you must use relative endpoint addresses for IIS-hosted service endpoints. Supplying a fully-qualified endpoint address can lead to errors in the deployment of the service.
07-30-2008 10:11 PM |
Got it. Thank you very much.