Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing an object through WCF service to silverlight
    text
    copied!<p>I have a WCF project within my Silverlight application. The WCF project uses Entity Framework to read from a database, i want to pass a list of objects that reflect rows to the Silverlight application this is the service contract;</p> <pre><code>[ServiceContract] public interface IGetToolboxItemsService { [OperationContract] List&lt;Control&gt; GetToolboxItems(); [OperationContract] string ReturnWord(string word); } </code></pre> <p>and here is the class that does the work</p> <pre><code>public class GetToolboxItemsService : IGetToolboxItemsService { public List&lt;Control&gt; GetToolboxItems() { SilverlightScreenDesignerEntities ent = new SilverlightScreenDesignerEntities(); List&lt;Control&gt; controls = new List&lt;Control&gt;(); controls = ent.Controls.ToList(); return controls; } public string ReturnWord(string word) { return word; } } </code></pre> <p>This is how i call the service in the client;</p> <pre><code>ToolboxServiceReference.GetToolboxItemsServiceClient proxy = new ToolboxServiceReference.GetToolboxItemsServiceClient(); proxy.GetToolboxItemsCompleted += proxy_GetToolboxItemsCompleted; proxy.GetToolboxItemsAsync(); </code></pre> <p>and then the completed event is here;</p> <pre><code>void proxy_GetToolboxItemsCompleted(object sender, ToolboxServiceReference.GetToolboxItemsCompletedEventArgs e) { var data = e.Result; } </code></pre> <p>when i debug the service it runs off to the database and brings back a list of <code>Controls</code> which is whats expected however i get the error message when trying to get the list of controls through the client.</p> <pre><code>The remote server returned an error: NotFound </code></pre> <p>yet when i try the simple return word, the service works fine and nothing breaks, is there an extra step thats needed because im passing through an object?</p> <p>Here is the web.config;</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt; &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt; &lt;/configSections&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0"&gt; &lt;assemblies&gt; &lt;add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt; &lt;/assemblies&gt; &lt;/compilation&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name=""&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; &lt;entityFramework&gt; &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt; &lt;parameters&gt; &lt;parameter value="v11.0" /&gt; &lt;/parameters&gt; &lt;/defaultConnectionFactory&gt; &lt;/entityFramework&gt; &lt;connectionStrings&gt; &lt;add name="ModelContainer" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=MOBINOTE135;initial catalog=BankManager;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt; &lt;add name="SilverlightScreenDesignerEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=MOBINOTE135;initial catalog=SilverlightScreenDesigner;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt; &lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload