4

I've created an app using MVVMCross, the IOS and Android versions are working but when I tried to "port" to WP7 and I ran into the following problem:

throw methodAccessException.MvxWrap("Problem accessing object - most likely this is caused by an anonymous object being generated as Internal - please see http://stackoverflow.com/questions/8273399/anonymous-types-and-get-accessors-on-wp7-1");

As mentioned in the answer to my other question about this (on Android) you have to set an InternalsVisibleTo attribute in the AssemblyInfo.cs for WP7. So I did:

[assembly: InternalsVisibleTo("Cirrious.MvvmCross.WindowsPhone")]

But this doesn't make any difference. I use the following code to send two variables form my BeckhoffViewModel to my BeckhoffSensorViewModel.

BeckhoffViewModel:

public IMvxCommand BeckhoffSensor1
{
get
    {
        return new MvxRelayCommand(kvpSens1);
    }
}

private void kvpSens1()
{
    RequestNavigate<BeckhoffSensorViewModel>(new { VarType = "short", Variable = ".countertest" });
}

BeckhoffSensorViewModel:

public BeckhoffSensorViewModel(string VarType, string Variable)
{
    _vartype = VarType;
    _variable = Variable;
}

Anything I'm overlooking? I also looked at the other stackoverflow topic mentioned in the exception but couldn't really understand it.

Stuart
  • 66,722
  • 7
  • 114
  • 165
David
  • 135
  • 1
  • 1
  • 5

1 Answers1

3

The anonymous class will most definitely be created as internal by the compiler - which is why you need the line [assembly: InternalsVisibleTo("Cirrious.MvvmCross.WindowsPhone")]

Can you check that the AssemblyInfo.cs file definitely being linked into the project (and that this is the project containing the ViewModel/anonymous-class code)?

If that is the case, can you check the methodAccessException to see what the message is?

If that doesn't help, can you use a tool like Reflector to check the internalVisible attribute is actually present on the core/application assembly?

Stuart
  • 66,722
  • 7
  • 114
  • 165
  • 1
    I guess I wasn't completely awake this morning. I added the attribute to the AssemblyInfo.cs file in the UI instead of the Core (/Library). After correcting that error it works fine! – David Apr 19 '12 at 12:18