DataServiceRequestException was unhandled when calling "SaveChanges()" in WCF application - wcf

So i keep getting this error when im trying to save changes in a WCF application
private void button1_Click(object sender, RoutedEventArgs e)
{
MBEMEADataContext cc = new MBEMEADataContext(new Uri("http://ldnmbl-sp10dev/sites/mbemea/_vti_bin/listdata.svc"));
cc.Credentials = System.Net.CredentialCache.DefaultCredentials;
var source = cc.CaseStudies;
cc.AddToCaseStudies(
new CaseStudiesItem
{
Title = textBox1.Text,
Client = textBox2.Text
});
cc.SaveChanges();
}
When cc.SaveChanges(); is called i get "DataServiceRequestException was unhandled" and i dont know why

Related

Consuming WCF with Xamarin form, completed args is null

I'm trying to consume a WCF Service in my xamarin forms app but I think I've a problem with my CompletedEventArgs because I've got a null object reference error (in the catch).
Here's my code :
private void callWCF()
{
try
{
ServiceRandom req = new ServiceRandom ();
req.InsertUserDetailsCompleted += req_InsertCompleted;
ProspectDetails prospectDetails = new ProspectDetails();
prospectDetails.Nom = "Test insertion appl";
req.InsertUserDetailsAsync(prospectDetails);
Test.Text = "ok";
}
catch (Exception ex)
{
Test.Text = ex.Message;
}
}
private void req_InsertCompleted(object sender, InsertUserDetailsCompletedEventArgs args)
{
string str = args.Result;
throw new NotImplementedException();
}

Duplicated output from process.OutputDataReceived

I'm having an issue with duplicated content from redirected output.
In my forms I have two buttons: Run and Clear.
public partial class BatchRun : Form
{
Process process = new Process();
public BatchRun()
{
InitializeComponent();
}
private void RunBTN_Click(object sender, EventArgs e)
{
//initiate the process
this.process.StartInfo.FileName = sMasterBATname;
this.process.StartInfo.UseShellExecute = false;
this.process.StartInfo.CreateNoWindow = true;
this.process.StartInfo.RedirectStandardOutput = true;
this.process.OutputDataReceived += new DataReceivedEventHandler(StandardOutputHandler);
this.process.StartInfo.RedirectStandardInput = true;
this.process.Start();
this.process.BeginOutputReadLine();
}
public void StandardOutputHandler(object sender, DataReceivedEventArgs outLine)
{
BeginInvoke(new MethodInvoker(() =>
{
Label TestLBL = new Label();
TestLBL.Text = text.TrimStart();
TestLBL.AutoSize = true;
TestLBL.Location = new Point(10, CMDpanel.AutoScrollPosition.Y + CMDpanel.Controls.Count * 20);
CMDpanel.Controls.Add(TestLBL);
CMDpanel.AutoScrollPosition = new Point(10, CMDpanel.Controls.Count * 20);
}));
}
private void ClearBTN_Click(object sender, EventArgs e)
{
CMDpanel.Controls.Clear();
this.process.CancelOutputRead();
this.process.Close();
this.process.Refresh();
}
}
This works great if I want to run process only once i.e. close the forms once process has completed.
However, I need to allow user to rerun the same process or run a new one hence I have added a clear button the clear various controls etc.
The problem I'm having is that after clicking clear button, I want to click run button again without closing which should then run the sMAsterBAT file(CMD).
StandardOutputHandler seems to be including content of the previous run as well as the new one resulting in duplicated labels in my CMDpanel.
Is this stored in some kind of buffer? If so, How do i clear it to allow me a rerun?
Could someone explain why this is happening and how to resolve it please.
Spoke to someone at work who fixed it for me. So easy lol
private void ClearBTN_Click(object sender, EventArgs e)
{
CMDpanel.Controls.Clear();
this.process.CancelOutputRead();
this.process.Close();
this.process.Refresh();
this.process = new Process(); // this line resolved my issue!!
}
}

ArgumentException While connecting win phone 8.1 to wcf

While building win phone 8.1 Silverlight,
Added service reference to WCF, some method for reference:
[OperationContract]
Task<GetPlayListResponse> GetPlayList(GetPlayListRequest request);
And using it like this:
private void Button_Click(object sender, RoutedEventArgs e)
{
var service = new MediaServiceClient();
service.GetPlayListCompleted += service_GetPlayListCompleted;
GetPlayListRequest request = new GetPlayListRequest { BusinessId = 41 };
service.GetPlayListAsync(request);
}
void service_GetPlayListCompleted(object sender, MediaService.GetPlayListCompletedEventArgs e)
{
var response = e.Result;
if (response.Result.ResultCode == eRequestResultCode.Success)
{
lb_RequestList.ItemsSource = response.Songs;
}
}
Getting the following error message:
[System.ArgumentException] {System.ArgumentException: Value does not fall within the expected range. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState) at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)} System.ArgumentException
The exception is accruing here :
public WinPhone.Silverlight_Client.MediaService.GetPlayListResponse EndGetPlayList(System.IAsyncResult result) {
object[] _args = new object[0];
WinPhone.Silverlight_Client.MediaService.GetPlayListResponse _result = ((WinPhone.Silverlight_Client.MediaService.GetPlayListResponse)(base.EndInvoke("GetPlayList", _args, result)));
return _result;
}

background worker dont work

I want to read a text file from the Internet and I want while reading the file a picturebox, that is a gif animation, show and after the reading is finished picturebox hide.
I use background worker. I have a lable that shows the state, but when I click BtnCheck Button bg doesn't work and the lable doesn't change.
My code:
private void Form1_Load(object sender, EventArgs e)
{
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.WorkerSupportsCancellation = true;
}
private void BtnCheck_Click(object sender, EventArgs e)
{
PbLoading.Visible = true;
if (backgroundWorker1.IsBusy != true)
{
// Start the asynchronous operation.
backgroundWorker1.RunWorkerAsync();
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
LbleState.Text = "Reading txt File...";
webClient1 = new WebClient();
if (CheckForInternetConnection())
{
try
{
Stream stream = webClient1.OpenRead(TxtWebAdrss);
StreamReader reader = new StreamReader(stream);
String content = reader.ReadToEnd();
reader.Close();
LbleState.Text = "Reading Finished .";
}
catch
{
LbleState.Text = "Error reading";
}
}
else LbleState.Text = "Internet not connected!";
}
You may just need to do a bit more research into this class. You should perform UI changes on the UI thread.
There are three event handlers that you can use and these are,
backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
The following link should help,
http://msdn.microsoft.com/en-us/library/System.ComponentModel.BackgroundWorker(v=vs.110).aspx

DOTMsn is not firing the SingedIn event

I have just started building a app using “XihSolutions.DotMSN.dll” version: 2.0.0.40909,
My problem is that it is not firing the “Nameserver_SignedIn” event. Not sure if I am doing something wrong.
your help will be really helpful.
void Nameserver_SignedIn(object sender, EventArgs e)
{
throw new Exception("User Signed In");
}
private string message = string.Empty;
void NameserverProcessor_ConnectionEstablished(object sender, EventArgs e)
{
message = "Connected";
SetMessage();
}
void SetMessage()
{
if (tbMessage.InvokeRequired)
tbMessage. Invoke(new ThreadStart(SetMessage));
else
tbMessage.Text += Environment.NewLine+ message;
}
private void btnSingIn_Click(object sender, EventArgs e)
{
if (messenger.Connected)
{
// SetStatus("Disconnecting from server");
messenger.Disconnect();
}
// set the credentials, this is ofcourse something every DotMSN program will need to
// implement.
messenger.Credentials.Account = tbUserName.Text;
messenger.Credentials.Password = tbPwd.Text;
// inform the user what is happening and try to connecto to the messenger network.
//SetStatus("Connecting to server");
messenger.Connect();
}
You might use MSNPSharp instead - DotMSN is old and may not support the current MSN protocol. There link is here:
http://code.google.com/p/msnp-sharp/