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

Mar 17, 2011 at 6: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 6: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

Coordinator
Mar 19, 2011 at 7:17 PM

Hi,

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

Thanks,

Laurent

Coordinator
Mar 19, 2011 at 7: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?

Thanks,

Laurent

Mar 19, 2011 at 7:29 PM

Hi,

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.

Thanks

Mar 19, 2011 at 7:49 PM

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

 

 

Coordinator
Mar 19, 2011 at 7: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.

Thanks!

Laurent

Coordinator
Mar 20, 2011 at 7: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: http://blog.galasoft.ch/archive/2011/03/20/mvvm-light-v4-preview-2-bl0015-mvvmlight.aspx

Cheers,

Laurent