locked
WCF is not getting called RRS feed

  • Question

  • Hi I'm calling a WCF service from an EXE(c# VS2008) . Its working fine if i double click the EXE.. but when i call the exe from a SQL job / statement its not getting called.

    Please see my EXE code

    static void Main(string[] args)
            { SmartConfig_svc.MessageClient mc = new ExecuteSmartConfigSchedules.SmartConfig_svc.MessageClient();
                try
                {             int I = mc.ExecuteSchedules(); 
                }
                catch (Exception ex)
                {
                    StreamWriter Sw; Sw = File.CreateText("F:\\Data\\mytext.txt");
                    Sw.Write(ex.Message); Sw.Close();
                }
            }

    In the webservice the ExecuteSchedules() method just retunrs zero
       public int ExecuteSchedules()
        {     return 0;   }

    If i run the EXE from a job/sql statement then i get below exception

    Type 'System.Data.SqlClient.SqlConnection' cannot be serialized.
     Consider marking it with the DataContractAttribute attribute,
    and marking all of its members you want serialized with the DataMemberAttribute attribute.

    posted the same on sqlserver forum

    http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/458f3d13-4f3b-438b-ac22-903ef9326937

    Any help would be much appreciated

    Thursday, November 10, 2011 9:33 AM

Answers

  • Hi,

    When the Sql job invokes your exe what is the context under which your exe runs. i.e the user account or permissions that have been setup for the job to use to run the exe.

    Also if you are trying to pass any parameters to the exe then make sure that they are serializable.

    Regards

    Rajesh


    Rajesh S V
    • Marked as answer by Yi-Lun Luo Wednesday, November 16, 2011 8:52 AM
    Thursday, November 10, 2011 4:43 PM

All replies