title: CRM Dynamics 2015 Plugin Cast Error, Specified Cast Is not valid
body: <p>Below is a snippet of the code for the plugin, I also added the WCF service to be consumed(code) as well.</p>
  
  <p>PLUGIN CODE BELOW</p>
  
  <pre><code>if (context.InputParameters.Contains("Target") &amp;&amp;  context.InputParameters["Target"] is Entity)
              {
  
              Entity phoneCallEntity = (Entity)context.InputParameters["Target"];
  
              if (phoneCallEntity.LogicalName != "phonecall")
                  return;
  
              if (context.MessageName == "Create")
              {
                  try
                  {
  
                      int NumberToCall = phoneCallEntity.Attributes.Contains("phonenumber") ? (int)phoneCallEntity.Attributes["phonenumber"] : 0;
                      int ReceiveCallOn = phoneCallEntity.Attributes.Contains("new_destination") ? (int)phoneCallEntity.Attributes["new_destination"] : 0;
                      string apiKey = phoneCallEntity.Attributes.Contains("new_apikey") ? phoneCallEntity.Attributes["new_apikey"].ToString() : null;
                      int fId = phoneCallEntity.Attributes.Contains("new_fid") ? (int)phoneCallEntity.Attributes["new_fid"] : 0;
  
                      BasicHttpBinding binding = new BasicHttpBinding();
                      binding.Name = "BasicHttpBinding_IService1";
  </code></pre>
  
  <p>Here i call the service</p>
  
  <pre><code> binding.SendTimeout = new TimeSpan(0, 10, 0);
   EndpointAddress endPointAddress = new EndpointAddress("http://localhost:62009/Service1.svc");
   ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(binding, endPointAddress);
   client.WebCall(NumberToCall, ReceiveCallOn, apiKey, fId);
  </code></pre>
  
  <p>Above I call the WCF Service</p>
  
  <pre><code>public void WebCall(Int64 NumberToCall, Int64 ReceiveCallOn, string APIkey, int FID)
      {
          string url = string.Format("https://xxxx{0},{1},{2}", NumberToCall, ReceiveCallOn, APIkey, FID);
          WebRequest webRequest = WebRequest.Create(url);
          WebResponse webResp = webRequest.GetResponse();
          webRequest.Method = "POST";
      }
  </code></pre>
  
  <p>Code snippet above is the actual WCF Service being consumed, So the issue is with the casting of the Number toi call and the <code>ReceiveCallOn</code> number, they are both cell phone numbers , in CRM they are a phone data type, any ideas why I cannot cast this.</p>