Sunday, June 29, 2014

CS1690:Accessing a member on 'member' may cause a runtime exception because it is a field of a marshal-by-reference class

I am having the same problem.


This is the code:



frmEmployeeContactEntry EmployeeContactEntryForm = new frmEmployeeContactEntry(public_var);
EmployeeContactEntryForm.employee_id = employee_id;

DialogResult employee_contact_form = EmployeeContactEntryForm.ShowDialog();

if (employee_contact_form == System.Windows.Forms.DialogResult.OK)
{
gridContacts.AddNewRow();
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_id", EmployeeContactEntryForm.employee_contact_id.ToString());
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_category_name", EmployeeContactEntryForm.cboCategory.Text);
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_details", EmployeeContactEntryForm.txtContact.Text.Trim());
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_description", EmployeeContactEntryForm.txtDescription.Text.Trim());
}



and the error occurs on this code:



EmployeeContactEntryForm.employee_contact_id.ToString()

employee_contact_id is an int in frmEmployeeContactEntry


public int employee_contact_id;


How can I fix it please


EmployeeContactEntryForm.employee_contact_id.ToString()

EmployeeContactEntryForm.employee_contact_id.ToString()

No comments:

Post a Comment