0

I'm currently having problem in my project. I'm having Code 4004 error in silverlight application. I don't know what I did wrong. Here are the image link.

http://s1100.photobucket.com/user/Fredi_Tansari/media/errorInsilverlight.png.html

here are the codes. After the the invalideoperation exception it goes to the unhandled exception error.

    private void getstatusCompleted(LoadOperation<PatientStatus1> obj)
    {
        try
        {
            PatientStatus1 bc = obj.Entities.First();
            if (bc != null)
            {
                MessageBox.Show("Patient has a status already, please use update instead new");
                return;
            }
            else
            {
                MessageBox.Show("inserting new Patient status");
            }
        }
        catch (InvalidOperationException e)
        {
            PatientStatus1 newPatientStatus = new PatientStatus1();
            newPatientStatus.ColorCodeID = "1";
            newPatientStatus.timestamp = DateTime.Now;
            newPatientStatus.UserID = "Jimmi";
            newPatientStatus.Patient_PatientID = Convert.ToInt32(patientIDTextBox.Text);
            newPatientStatus.MasterPatientStatus_masterPatientStatusId = Convert.ToInt32(masterPatientStatusIdTextBox.Text);
            newPatientStatus.MasterLocation_masterLocationID = Convert.ToInt32(masterLocationIDTextBox1.Text);
            patientstatusDomainContext.PatientStatus1s.Add(newPatientStatus);
            patientstatusDomainContext.SubmitChanges();

        }



    }

Thanks in advance for the help

8
  • Why are you putting object creation code in your catch-block? Can't you prevent invalidoperationexceptions from happening instead of catching it? And which code of line causes the next exception?
    – Terry
    Commented Jun 12, 2013 at 9:01
  • Hi there Djerry, after the patientdomaincontext.submitchanges(); I'm seriously stumped right now. I just want to check if the data already exist in the database or not when I decided to use the try-catch, feel free to suggest better way to do it. Commented Jun 12, 2013 at 9:07
  • I guess you're using entity framework, so I won't suggest work methods as I'm not that familiar. What you can do now is put a try-catch around the line that generates the error (you can remove this try catch later when you've found what causes this). The errors SL throw are sometimes confusing, so see what the error tells you.
    – Terry
    Commented Jun 12, 2013 at 9:12
  • i'll try to do that.. I'll post the result as soon as i'm done Commented Jun 12, 2013 at 9:17
  • @djerry, I tried to put the try catch, I think this has to do with the domain service operation issue.The entire operation is actually performed and then it goes to the exception. Commented Jun 12, 2013 at 9:27

1 Answer 1

1

Try to set this key value to 1.

HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings\JITDebug

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.