Export (0) Print
Expand All
Expand Minimize

Compiler Warning (Level 1) CS1690 

Error Message

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

This warning occurs when you try to call a method, property, or indexer on a member of a class that derives from MarshalByRefObject, and the member is a value type. To resolve the warning, copy the member into a local variable and call the method on that variable.

The following sample generates CS1690:

// CS1690.cs
using System;

class WarningCS1690: MarshalByRefObject
   int i = 5;

   public static void Main() 
     WarningCS1690 e = new WarningCS1690();
     e.i.ToString();   // CS1690

     // OK
     int i = e.i;
     e.i = i;

Community Additions

© 2015 Microsoft