Note that there are some explanatory texts on larger screens.

plurals
  1. POEach time I open Visual Studio the FileSystemWatcher EnableRaisingEvent changes
    primarykey
    data
    text
    <p>I'm using C# in Visual Studio 2010 with the framework 4.0.</p> <p>In my project, in two different forms, there are two <code>FileSystemWatcher</code>s with the property <code>EnableRaisingEvent</code> set to <code>false</code>. If I close Visual Studio, when I reopen it I get in both <code>FileSystemWatcher</code> the property <code>EnableRaisingEvent</code> set to <code>true</code>.</p> <p>In both my forms in the designer file there is the following code:</p> <pre><code>private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.fileSystemWatcher1 = new System.IO.FileSystemWatcher(); ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).BeginInit(); this.SuspendLayout(); this.fileSystemWatcher1.Filter = "my_filter"; this.fileSystemWatcher1.NotifyFilter = System.IO.NotifyFilters.LastWrite; this.fileSystemWatcher1.SynchronizingObject = this; this.fileSystemWatcher1.Changed += new System.IO.FileSystemEventHandler(this.fileSystemWatcher1_Changed); } </code></pre> <p>The property <code>EnableRaisingEvent</code> is not set, but the default is <code>false</code>.</p> <p>Any idea why I get this strange behaviour?</p> <p><strong>edit</strong></p> <p>I followed the Virtlink's suggestion, adding the following line of code:</p> <pre><code>this.fileSystemWatcher1.EnableRaisingEvents = false; </code></pre> <p>It seemed to solve my problem, but after a few days (and some opening, closing and rebuilding of the project, but without modifying the <code>fileSystemWatcher1</code>) I found:</p> <ul> <li><p>in the designer, in the properties of the <code>fileSystemWatcher1</code>, <code>EnableRaisingEvents</code> was set back to <code>true</code></p></li> <li><p>in the code, the line previously added was missing</p></li> </ul> <p>I tried moving to Visual Studio 2012 (still framework 4.0) and the workaround fixed the problem for some more days. Then I got the same situation as in VS10. </p> <p>Any other idea?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload