MVVM Light obtained via NuGet - RelayCommand.cs no

2019-01-20 14:07发布

My program incorporates a copy of MVVM Light via NuGet. Up until about 5 minutes ago it worked without a hitch, but now I'm getting an error saying "RelayCommand.cs not found". Since I got the package from NuGet, I don't have RelayCommand.cs itself, just the dll. I have tried uninstalling and reinstalling MVVM Light and the problem persists. Right now I really am at a loss. If anybody could help me fix this so that I can continue working I would greatly appreciate it.

Locating source for 'd:\GalaSoft\mydotnet\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight (NET35)\Command\RelayCommand.cs'. Checksum: MD5 {9c e1 3c 59 78 15 34 23 2b e 9b 39 ef 5d eb d0}
The file 'd:\GalaSoft\mydotnet\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight (NET35)\Command\RelayCommand.cs' does not exist.
Looking in script documents for 'd:\GalaSoft\mydotnet\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight (NET35)\Command\RelayCommand.cs'...
Looking in the projects for 'd:\GalaSoft\mydotnet\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight (NET35)\Command\RelayCommand.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\vccorlib\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: d:\GalaSoft\mydotnet\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight (NET35)\Command\RelayCommand.cs.
The debugger could not locate the source file 'd:\GalaSoft\mydotnet\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight (NET35)\Command\RelayCommand.cs'.

Update: At this point I'm thinking that this is a problem with VS. I downloaded the dll files manually and referenced them and I'm still getting the same error. I'm thinking it might just be worth it to make a new project and migrate my data. If anybody has any ideas on how to fix this, though, I'm all ears.

Update: I don't know if this could be the issue, but it appears that the program is looking for MvvmLight (NET35). The version I obtained (and had working up until now) is WPF45.

Update: When I open packages.config in my solution, I get a warning that says "The 'packages' element is not declared." Could this be relevant?

3条回答
我命由我不由天
2楼-- · 2019-01-20 14:49

I don't know why this would cause such an error, but I believe it was caused by trying to read in data from a file that didn't exist. I removed that code and the error went away.

查看更多
欢心
3楼-- · 2019-01-20 15:07

Got just the same Problem with Galasoft and found your post. - Finally I figured it out, or at least the error no longer pops up:

Go to Tools-Options...-Debugging-General and tick Enable Just My Code and the error disappeared. I assume MVVM-Light is compiled in Debug Mode and now Visual Studio Looks for the MvvmLight pdb and cs file which are of course not there when installed via nuget.

查看更多
我只想做你的唯一
4楼-- · 2019-01-20 15:12

When I got this error it was because of an invalid cast exception. I had this:

MyCommand = new RelayCommand<int>((i) => MyMethod(i));

But the property I was Binding in my XAML was a long. I changed it to this and it worked:

MyCommand = new RelayCommand<long>((i) => MyMethod(i));
查看更多
登录 后发表回答