This project has moved and is read-only. For the latest updates, please go here.

Error Compiling and using newest GalaSoft.MvvmLight (NET4) release.

Mar 17, 2011 at 7:11 PM

While compiling, in both release and debug modes, I'm getting the following error.

Error loading C:\Users\danigre\Downloads\mvvmlight-5056f53e22e0\mvvmlight_5056f53e22e0\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Test (NET4)\bin\Release\GalaSoft.MvvmLight.Test.WPF4.dll: Unable to load the test container 'C:\Users\danigre\Downloads\mvvmlight-5056f53e22e0\mvvmlight_5056f53e22e0\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Test (NET4)\bin\Release\GalaSoft.MvvmLight.Test.WPF4.dll' or one of its dependencies. Error details: System.TypeLoadException: Inheritance security rules violated by type: 'GalaSoft.MvvmLight.Command.EventToCommand'. Derived types must either match the security accessibility of the base type or be less accessible.

This makes no sense to me, as both EventToCommand and TriggerAction<T> are public, and seem to have the same signature for all overrides (protected abstract void Invoke(object parameter) , protected virtual void OnAttached())  So I ask, what could be causing this error to occur? 

Please note, I have not made any changes to the source, but I am running with VS2010 + SL Tools + Visual Studio 2010 Async CTP.




Mar 19, 2011 at 7:39 PM

I was getting the same error. The workaround is to remove from the projects AssembyInfo.Net4.cs the attribute AllowPartiallyTrustedCallers, i guess the problem is the System.Windows.Interactivity dll doesn't allow partial trust

Mar 19, 2011 at 8:17 PM


AllowPartiallyTrustedCallers should not be a problem. Actually I can build just fine here. Something else must be an issue here, I will investigate.



Mar 19, 2011 at 8:25 PM

Just to be clear: You need to remove the AllowPartiallyTrustedCallers attribute from AssembyInfo.Net4.cs if you want to run the unit tests. I will put together a page explaining this. However you should be able to build the code without removing this attribute.

Can you confirm that the error is when you build the project, and not when you run the tests?



Mar 19, 2011 at 8:29 PM


For me the error is when i try to run the tests but i also get the error if i try to use the EventToCommand in my project, a WPF4 ClientProfile application.


Mar 19, 2011 at 8:49 PM

As with bdscoder, I built, and used in another project, and EventToCommand seems to be the failing point.



Mar 19, 2011 at 8:53 PM

OK guys, thanks for the precision, I will check that out. AllowPartiallyTrustedCallers is needed to run the code in XBAPs, but if it causes issues in other parts, it is of course a difficult situation.



Mar 20, 2011 at 8:40 PM

For info I just published a new version (BL0015) where, amongst other fixes and changes, I removed the AllowPartiallyTrustedCallers attribute. I will check out what the issue is and hopefully restore that soon, but without the problem that you guys reported.

More info: