locked
serious help with database operations with wcf RRS feed

  • Question

  • I'm so lost guys, please help.

    I have a silverlight client that i want to get and write data to a DB located on the server . now this is what i did :

    1. created the silverlight projecte hosted in asp site project, with wcf enabled .

    2. created a DB with some tables in it.

    3. created linq to sql classes, and wcf service with operation to fetch data from the DB, added the project the referance .

    result:

    when i debug it locally on localhost, it workes perfectly, but when i upload all the content to the server i get an error, my guess is that the service is not finding the DB .

    after I uploaded the content, all i did was change the connection string in my web.config file to the one provided to me by the hosting server.

    seriously guys, i need some real step by step help, on deployment in server side or somthing. cos im soooooo lost .

    Thursday, December 30, 2010 7:54 PM

Answers

All replies

  • Where I work, we are very locked down by firewall rules.  So what works on one server may not work on another. 

    You can try "Telnet SQLServerMachinename Port#" to see if that server has access to that SQL server or not.

    Neal

     

    Friday, December 31, 2010 12:05 AM
  • Hi,

    Can you tell us what exception you have and the message you've got?

    This will help us to help you.

    Thanks

    Binze


    Binze Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 31, 2010 11:34 AM
  • hi, ofcourse i wil give all the details :

    first, this is the exception my browser shows me, it all happens in the userControl_Loaded event, so i will give you the code there too :

    Exception:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)
    Timestamp: Fri, 31 Dec 2010 12:11:43 UTC
    Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
       at MyProfile.ServiceReference1.GetMessagesCompletedEventArgs.get_Result()
       at MyProfile.MainPage.webService_GetMessagesCompleted(Object sender, GetMessagesCompletedEventArgs e)
       at MyProfile.ServiceReference1.ServiceClient.OnGetMessagesCompleted(Object state)
    Line: 1
    Char: 1
    Code: 0

    now take a look at my code (Notice : it workes fine when debug on my local machine on localhost)

    private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
    		{
    			AnimateVerticalString(true);
          //test
          ServiceReference1.ServiceClient webService = new ServiceReference1.ServiceClient();
          webService.GetMessagesCompleted += new EventHandler<ServiceReference1.GetMessagesCompletedEventArgs>(webService_GetMessagesCompleted);
          webService.GetMessagesAsync();
    		}
    
        void webService_GetMessagesCompleted(object sender, ServiceReference1.GetMessagesCompletedEventArgs e)
        {
          this.dataGrid1.Visibility = System.Windows.Visibility.Visible;
          this.dataGrid1.ItemsSource = e.Result;
        }
    

    finally, as i suspect web.config is not configured right, this is my web.config file :

    <?xml version="1.0"?>
    <configuration>
    
     <system.diagnostics>
      <sources>
       <source name="System.ServiceModel"
           switchValue="All"
           propagateActivity="true">
        <listeners>
         <add name="traceListener"
           type="System.Diagnostics.XmlWriterTraceListener"
           initializeData= "Traces.svclog" />
        </listeners>
       </source>
      </sources>
     </system.diagnostics>
     
    	<connectionStrings>
     <add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
      providerName="System.Data.SqlClient" />
     </connectionStrings>
     <system.web>
    		<compilation debug="true" targetFramework="4.0">
    			<assemblies>
    				<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
    	</system.web>
     <system.serviceModel>
     <client>
      <endpoint address="http://localhost:4064/MyProfileSite/Service.svc"
      binding="customBinding" bindingConfiguration="CustomBinding_Service"
      contract="ServiceReference1.Service" name="CustomBinding_Service" />
     </client>
     <behaviors>
      <serviceBehaviors>
      <behavior name="">
       <serviceMetadata httpGetEnabled="true" />
       <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
      </serviceBehaviors>
     </behaviors>
     <bindings>
      <customBinding>
      <binding name="Service.customBinding0">
       <binaryMessageEncoding />
       <httpTransport />
      </binding>
      <binding name="CustomBinding_Service">
       <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
       maxSessionSize="2048">
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
       </binaryMessageEncoding>
       <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
       maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
       bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
       keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
       realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
       useDefaultWebProxy="true" />
      </binding>
      </customBinding>
     </bindings>
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
     <services>
      <service name="Service">
      <endpoint address="" binding="customBinding" bindingConfiguration="Service.customBinding0"
       contract="Service" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
     </services>
     </system.serviceModel>
      
    </configuration>
    
    

     

    thats it. in my web.config file all i did before uploading to server, is to change the connection string to the one provided to me by the host.

    but as i see, there are more configurations need to be done, i just don't know what.

    please help folks!!

    Friday, December 31, 2010 12:17 PM
  • Hi,

    Check the following thread for solution:

    http://forums.silverlight.net/forums/p/197819/460733.aspx

    Make sure the endpoint adress is setup correctly.

    Thanks

    Binze


    Binze Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bin-ze Zhao Wednesday, January 5, 2011 7:43 AM
    Monday, January 3, 2011 6:36 AM
  • thank you.

     

    will this affect all the other [service_reference] files, which i checked, and they are all pointing to my localhost?

    and 2nd, if this is still not working, maybe i'm putting the connection string of the DB on the host side wrong??

    this is connection string :

    workstation id=usercomments.mssql.somee.com;packet size=4096;user id=abcd1234;pwd=abcd1234;data source=usercomments.mssql.somee.com;persist security info=False;initial catalog=usercomments

    i also had to create login to attach my mdf file to their DB server.

    what is the correct syntax to change in web.config??

    Thursday, January 6, 2011 11:08 AM