I have a Silverlight 2 app that sends a byte array to a Silverlight-enabled WCF service. However, (unless I try to upload a .txt file) the service's SaveFile()
method is never reached and I get an error: "The remote server returned an error: NotFound"
Am I missing something really obvious? Why can't I upload .doc files? Why only .txt?
UPDATE: I've tried attaching debugger for CLR exceptions, but that didn't help. I am still not able to see any errors besides the 404. Here's my code:
in Page.xaml.cs:
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog().Value)
{
byte[] fileContent = new byte[dlg.File.Length];
using (FileStream fs = dlg.File.OpenRead())
{
fs.Read(fileContent, 0, Convert.ToInt32(fs.Length));
fs.Close();
}
Service1.Service1Client srv = new SL1.Service1.Service1Client();
srv.SaveFileCompleted += (sender1, e1) =>
{
foo.Text = "Uploaded!";
};
srv.SaveFileAsync(dlg.File.Name, fileContent);
}
in Service1.svc.cs:
[OperationContract]
public string SaveFile(string fileName, byte[] fileContent)
{
string ret = String.Empty;
try
{
string target = @"c:\debug123\" + fileName;
if (File.Exists(target))
{
File.Delete(target);
}
File.WriteAllBytes(target, fileContent);
ret = "OK";
}
catch (Exception ex)
{
ret = ex.ToString();
}
return ret;
}
Anyone see anything wrong with this?