Skip to main content

Microsoft Silverlight

Answered Question datagrid problemRSS Feed

(0)

kevsbox
kevsbox

Member

Member

3 points

26 Posts

datagrid problem

Hi

While running my code through VS2008 my grids populate correctly. However same code published and uploaded to a test domain returns empty grids.

The domain is www.tisconi.com. The 2-5th buttons on the left return data on my PC but nothing on the remote site.

Any thoughts please.

Thanks

 

Kev

Tim Dawson
Tim Dawson

Participant

Participant

1092 points

209 Posts

Re: datagrid problem

It could be virtually anything. You'll need to be a little more specific than that, ideally showing us the XAML used to define the grid in question and any relevant binding code. And tell us where you're getting the data from.


Microsoft MVP
Controls for Silverlight, WPF and Windows Forms at http://www.divelements.co.uk

kevsbox
kevsbox

Member

Member

3 points

26 Posts

Re: datagrid problem

Hi Tim

Below is the xaml code for the grid

        <data:DataGrid x:Name="dg" AlternatingRowBackground="Beige" AutoGenerateColumns="False"
                       VerticalAlignment = "Top" Width="300" Height="600" Grid.Row="2"
                       Grid.Column="1" Background="White" CanUserResizeColumns="False"
                       BorderThickness="0" HorizontalScrollBarVisibility="Hidden"
                       IsReadOnly="True">
            <data:DataGrid.Columns>
                <data:DataGridTextColumn Width="300" Binding="{Binding name}" />
            </data:DataGrid.Columns>
        </data:DataGrid>

 

The data is a MSSQL server database, as previously stated the grid populates when running the app from within VS2008, data can also be viewed at - http://www.kevsbox.com/spice/Default.aspx (the ye olde non silverlight site).

Server side uses a MSLinqToSQLGenerator connection to the db. There is also WCF Service , example code below -

public List<currytypes> chinIndex()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var matchingRec = from recs in db.currytypes
                              where System.Convert.ToString(recs.ctype) == "H"
                              orderby recs.ndx
                              select recs;
            return matchingRec.ToList();
        }

The client side links to this with a service reference.

Previously I had a problem with cross domain calls until I added clientaccesspolicy.xml and crossdomain.xml. 

I remember reading somewhere about setting port numbers, could this be the issue?

Regards

 

 

kevsbox
kevsbox

Member

Member

3 points

26 Posts

Re: datagrid problem

Further I have identified these error messages - Anyone seen anythinhg like this before?

Firefox

Error: Unhandled Error in Silverlight 2 Application An exception occurred during the operation, making the result invalid. 
Check InnerException for exception details.   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()  
at spicetheworld.ServiceReference1.curryIndexCompletedEventArgs.get_Result()  
at spicetheworld.recipeGrid.webService_curryCompleted(Object sender, curryIndexCompletedEventArgs e)  
at spicetheworld.ServiceReference1.Service1Client.OncurryIndexCompleted(Object state)
Source File: http://www.tisconi.com/recipeList.aspx?param=curry
Line: 0

IE

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)
Timestamp: Wed, 24 Jun 2009 14:29:31 UTC


Message: Unhandled Error in Silverlight 2 Application An exception occurred during the operation, making the result invalid. 
Check InnerException for exception details.   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()  
at spicetheworld.ServiceReference1.curryIndexCompletedEventArgs.get_Result()  
at spicetheworld.recipeGrid.webService_curryCompleted(Object sender, curryIndexCompletedEventArgs e)  
at spicetheworld.ServiceReference1.Service1Client.OncurryIndexCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://www.tisconi.com/recipeList.aspx?param=curry

 

kevsbox
kevsbox

Member

Member

3 points

26 Posts

Re: datagrid problem

 Hi Foks

I still have this problem. To refresh. My code when running locally via Visual Studio 8 fills a grid correctly with data from a MS SQL database which is on a remote server. This tells me the code is correct and the connection string must be valid. However when I post the code to its remote test site (www.tisconi.com) gthe grid fails to fill with data. There is no change in code the only difference is the site is now remote and not running from my local machine.

Silverlight is running correctly at the remote site, the buttons are also a silver light control and they function correctly.

Someone must have come across this before. Help please..

 

 

clint1222
clint1222

Participant

Participant

1426 points

198 Posts

Re: datagrid problem

Hi,

 When you're creating the web service client, you use the default constructor.

Service1Client client = new Service1Client();

When using the default constructor, the app gets the service address from the ClientConfig file contained in the xap file.  Currently the service host is set up as:

 http://localhost:4688/Service1.svc

You need up either update the Service reference to point to your production service and rebuild the app, or specify the web service address when creating the Service1Client. 

You could also just update the ClientConfig file inside the xap file to point to the production web service.

 

 

 

rshelby
rshelby

Member

Member

273 points

64 Posts

Re: datagrid problem

I ran into this problem several weeks ago.  I had a webservice called SiteMapService that worked on my development machine, but when I moved it to the test server I had the same problem as you. 

Below is an example of what I did to fix the problem so the endpoints would work on both my development machine and production.  For the SoapName, look inside your ServiceReferences.ClientConfig file.  The soap uri is just the location of the asmx file.

Dim mySoapName As String = "SiteMapServiceSoap"
Dim mySoapURI As String = "../SiteMapService.asmx"
Dim myAddress As Uri = New Uri(Application.Current.Host.Source, mySoapURI)
Dim SMClient as SiteMapService.SiteMapServiceSoapClient = New SiteMapService.SiteMapServiceSoapClient(mySoapName, myAddress.AbsoluteUri)

Once I changed it to this, my services all started working.  Hope this helps.

rshelby

Ryan Shelby

rshelby.com

kevsbox
kevsbox

Member

Member

3 points

26 Posts

Re: datagrid problem

 Hi clint1222

Thanks for the response.  Below is my ServiceReferences.ClientConfig file. So are you saying I should change the endpoint address to the second example?


<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:4688/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
                name="BasicHttpBinding_IService1" />
        </client>
    </system.serviceModel>
</configuration>


<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://www.tisconi.com:4688/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
                name="BasicHttpBinding_IService1" />
        </client>
    </system.serviceModel>
</configuration>

rsdhelby, thanks for the response, I use C# but will try your suggestion next,

Regards

Kev

clint1222
clint1222

Participant

Participant

1426 points

198 Posts

Re: datagrid problem

Hi Kev,

It's one possible solution except I don't think your service is listening on port 4688.  I think the address is http://www.tisconi.com/Service1.svc.

If you don't want to fiddle with the ClientConfig file, you can dynamically build the address based on the host location as rsdhelby showed you.

 

Binding binding = new BasicHttpBinding();
EndpointAddress remoteAddress = new EndpointAddress(new Uri(Application.Current.Host.Source, "../Service1.svc"));
ServiceReference1.Service1Client slService = new ServiceReference1.Service1Client(binding, remoteAddress);
 

 

rshelby
rshelby

Member

Member

273 points

64 Posts

Re: datagrid problem

Sorry about the vb.  Here's the example again.  Pretty much the same as Clint's example.

string mySoapName = "SiteMapServiceSoap";
string mySoapURI = "../SiteMapService.asmx";
Uri myAddress = new Uri(Application.Current.Host.Source, mySoapURI);
SiteMapService.SiteMapServiceSoapClient SMClient = new SiteMapService.SiteMapServiceSoapClient(mySoapName, myAddress.AbsoluteUri);

Ryan Shelby

rshelby.com

kevsbox
kevsbox

Member

Member

3 points

26 Posts

Re: datagrid problem

  Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

Hi Guys

Thanks for the info, I have tried what you suggest but still get the same issue. The grid fills correctly when running local via VS 2008 but fails when uploaded to the domain. This is so very frustrating and is probably something so silly I will kick myself when it is resolved. Here goes again.

Server side –

Web.config section

  <services>

   <service behaviorConfiguration="spicetheworld.Web.Service1Behavior"

    name="spicetheworld.Web.Service1">

    <endpoint address="" binding="basicHttpBinding" contract="spicetheworld.Web.IService1">

     <identity>

      <dns value="localhost" />

     </identity>

    </endpoint>

    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

   </service>

  </services>

 

Service files

IService1.cs & Service1.svc

 

Client Side –

ServiceReferences.ClientConfig

<configuration>

    <system.serviceModel>

        <bindings>

            <basicHttpBinding>

                <binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"

                    maxReceivedMessageSize="2147483647">

                    <security mode="None" />

                </binding>

            </basicHttpBinding>

        </bindings>

        <client>

            <endpoint address="http://localhost:4688/Service1.svc" binding="basicHttpBinding"

                bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"

                name="BasicHttpBinding_IService1" />

        </client>

    </system.serviceModel>

</configuration>

 

App.xaml

        public App()

        {

            this.Startup += this.Application_Startup;

            this.Exit += this.Application_Exit;

            this.UnhandledException += this.Application_UnhandledException;

 

            InitializeComponent();

 

            Binding binding = new BasicHttpBinding();

            EndpointAddress remoteAddress = new

                EndpointAddress(new Uri(Application.Current.Host.Source, "../Service1.svc"));

            ServiceReference1.Service1Client slService =

                new ServiceReference1.Service1Client(binding, remoteAddress);

 

        }

 

Service reference is called ServiceReference1

 

If anyone can see a problem with these settings then please let me know. If anyone is willing to browse the project I will will be happy to zip it and send via direct email.

Regards

 

Kevin

clint1222
clint1222

Participant

Participant

1426 points

198 Posts

Answered Question

Re: datagrid problem

Hi Kevin,

The App constructor code isn't doing anything.  Upon exit of the App constructor the binding, remoteAddress, and slService objects are no longer accessible and marked for garbage collection.

In the Page_Loaded method of your recipeGrid control, you use the default contructor in the following line of code:

Service1Client client = new Service1Client();

Then you call the appropriate async method inside the switch block.  The default construct gets the address of the service from the ClientConfig file.  The ClientConfig setting for the service address is back to localhost.  This means the code will only execute correctly on the same machine.

To solve your issue you either have to: 

correct the clientconfig setting, specifying the machine name or domain name instead of localhost:4688 for each deployment environment;

or

specify the specific address of the service in code (use a different overload than the default) and recompile for each deployment environment;

or

if the service is hosted at the same location as the host of your Silverlight app, then you can dynamically build the address base on the Application.Current.Host.Source property and not worry about the different deployment environments.

(if you want to send me the project I'll take a look, or just the recipeGrid.xaml.cs file is fine)

 

kevsbox
kevsbox

Member

Member

3 points

26 Posts

Re: datagrid problem

Hi All

Clint, thanks for your help. Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

 

I have contacted my host in regard to this problem, below is their response.

------------------------------------------------------------------------------

Hello,

 

When browsed in IE8 it gave an error in the system event logs, which was:

 

"The exception message is: This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection."

 

Hence we applied the fix at:

 

http://blogs.msdn.com/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx

 

and added few line in your web.config.

 

Though the above error was fixed we now get following error in IE after some time of loading the page:

 

====================================================================

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.30729)

Timestamp: Tue, 30 Jun 2009 20:28:54 UTC

Message: Unhandled Error in Silverlight 2 Application [Async_ExceptionOccurred]

Arguments:

Debugging 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.40115.0&File=System.dll&Key=Async_ExceptionOccurred   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()

   at spicetheworld.ServiceReference1.curryIndexCompletedEventArgs.get_Result()

   at spicetheworld.recipeGrid.webService_curryCompleted(Object sender, curryIndexCompletedEventArgs e)

   at spicetheworld.ServiceReference1.Service1Client.OncurryIndexCompleted(Object state)

Line: 1

Char: 1

Code: 0

URI: http://www.tisconi.com/recipeList.aspx?param=curry

====================================================================

 

Please feel free to contact us if you need any further assistance.

---------------------------------------------------------------------------------------------------------------------------------------------------------------

This is what the added to web.config

  <serviceHostingEnvironment>

    <baseAddressPrefixFilters>

      <add prefix="net.tcp://www.tisconi.com:80"/>

      <add prefix="http://www.tisconi.com:80"/>

    </baseAddressPrefixFilters>

  </serviceHostingEnvironment>

 

Still does not work, still same problem, anyone got any thoughts please?

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities