4

I'm seeing a strange build bug a lot. Sometimes after typing some code we receive the following build error.

Class 'clsX' must implement 'Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs)' for interface System.ComponentModel.INotifyPropertyChanged'.   

And

'PropertyChanged' cannot implement 'PropertyChanged' because there is no matching event on interface 'System.ComponentModel.INotifyPropertyChanged'.

Those error should never go together! Usually we can just ignore the exception and build the solution but often enough this bug stops our build. (this happens a lot using Edit and Continue which is annoying)

We're using Vb.net and c# mixed in one big solution.

Removing the PropertyChanged event and retyping the same code! sometimes fixes this.

Question:

Has anyone else seen this problem and has some suggestions how to prevent his?

We're using a code generator that causes this error to surface but just editing some files manually triggers this exception too. This error occur's on multiple machines using various setups.

CodingBarfield
  • 3,392
  • 2
  • 27
  • 54
  • 1
    Could you post some reproducing code? It's not clear what your code is or what your bug is or what you're doing exactly. The VB or C# compiler always produces the same result with the same input. – Simon Mourier Jan 15 '12 at 07:24
  • @SimonMourier Visual studio doesn't likes mixed projects combining VB and C#. It forgets to recompile DLL's or copy update them. In some/this situation the Compiler OR Visual Studio produces NO results with correct input. – CodingBarfield Jan 17 '12 at 07:17

4 Answers4

2

Someone had the same exact issue discussed here. It sounds like there is an issue with this build picking up an old version of a binary. I would try the following in order:

  • Verify all assembly references use project references where possible within the Visual Studio solution.
  • Disable build parallelization in case there is some weird file locking issue with concurrent project builds. Go to Tools -> Options, Projects and Solutions -> Build and Run, then set "maximum number of parrellel project builds" to 1. Not the best solution but it may help narrow down the problem.
  • Disable the Hosting Process in case it's locking some file causing an assembly to not get rebuilt correctly. For C# project go to Project Properties, Debug tab, and uncheck "Enable the Visual Studio hosting process". For VB.NET project you'll need to Unload Project, Edit the project file, and add <UseVSHostingProcess>false</UseVSHostingProcess> to the PropertyGroup of each configuration. Again, not the best solution but you probably won't notice a difference.
  • Lastly, try doing a Clean + Build to try and resolve the issue when it occurs (I know this is not a fix but it's easy enough to do), also Rebuild may be slightly different than Clean + Build so try the latter if the former doesn't work.
Community
  • 1
  • 1
Scott Lerch
  • 2,620
  • 1
  • 23
  • 34
2

As I can not comment due to lack of appropriate points. But I would like to share one of my experience:

In an aspx.cs page I was working, used to compile fine and some time gave mysterious error of a variable not defined or function not defined or sometime variable or the function defined two times. I changed possibly each and every variable and function name but there seemed no effect , but after entering a simple space or a new line at any place in the file used to solve the compile error. At one time I tried to save the file (in a different encoding as i am used to experiments) and found that the file was not saving in the correct encoding (i.e. the ansi encoding because the file had a unicode character ), I removed the unicode character and that compile error didn't bothered me again.

This unicode character problem could be (not a hard and fast rule) there so you could check it.

Anand M Arora
  • 372
  • 3
  • 8
  • Great suggestion. Too bad this wasn't the problem. It can pop up on files that haven't been touched in a while. Or files that are edited in VS.Net which should repair the files on saving them. – CodingBarfield Jan 18 '12 at 14:31
  • 1
    Understand that this isn't the problem, but regarding unicode, I've had situations where I pasted stuff directly into a string in my code in VS.Net, it was (unknown to me) having wierd unicode stuff in it, and it saved the whole file in unicode without telling me or fixing it. Some kind of error did complain about unicode though so it was not a difficult problem, I think I solved it by pasting in notepad and copying back or something like that. – FastAl Jan 18 '12 at 15:13
1

Nuke & restore using source control (TFS instructions here):

  • Make sure you have everything checked in
  • Exit Visual Studio
  • Rename the project directory to .Bak (effectively deleting it)
  • Reopen Visual Studio and in source control:
    • Get Specific Version
    • check 'Overwrite... not checked out' and 'Overwrite ... even if local version matches'
  • Re-open project

Another problem: Make sure some source files are not newer than the current date (or your date is set back). Often this happens in apps where you are doing logic that requires certain things to happen differently on certain dates. You change your clock to test it, make a revision to the source with the date advanced, set the date back, and viola, rebuild does not rebuild that file.

You say 'typing it in again' - can you try just saving? After 40 years since MULTIX the .net build still decides what has changed by checking the file timestamp.

good luck!

FastAl
  • 6,194
  • 2
  • 36
  • 60
  • Typing it again works most of the time. But for some reason not always. The most annoying thing is that we generate those code files and have to manually restore the files after each new generate. – CodingBarfield Jan 17 '12 at 07:18
  • And we have to really change the lines of code involved. Changing another function completely won't solve the build problem. – CodingBarfield Jan 18 '12 at 07:47
1

When you get the error, is it always on the VB calling C# side, or vice-versa, or does it work both ways?

If the answer is either of the first two situations, try building the "callee" project within the solution before building the "caller" project to see if it stops the situation.

Also, just in case it may jog something for you to think about, does this error crop up when you change a VB file or a C# file, or is there no correllation?

Oh, and sorry this looks like an answer instead of a comment, I cannot post comments yet (need 50 rep).

APrough
  • 2,671
  • 3
  • 23
  • 31
  • Its on the declaration side which is mostly VB code. Building the project itself won't help. It simply won't compile due to the given error. – CodingBarfield Jan 18 '12 at 07:35