I've created small portable library (reference, targeting: Windows, Windows 8, Windows Phone 7.5) for educational purposes. I've decided to use it in my small Windows 8 Metro style app. Unfortunately, when I call method from the library the exception is thrown:
The application called an interface that was marshalled for a different thread.
at the following line:
return Activator.CreateInstance(outputType, constructorArguments.ToArray());
(Resolve method) The outputType is a typeof(ClassFromMyMetroStyleApp). Library is added to project as dll reference.
What can I do to fix this issue?
Edit: Method is call from UnitTest in Metro Style App solution:
[TestClass]
public class ResolvingTypesTests
{
    /// <summary>
    /// The school context interface test.
    /// </summary>
    [TestMethod]
    public void SchoolContextTest()
    {
        var schoolContext = TypeService.Services.Resolve<ISchoolContext>();
        Assert.AreEqual(typeof(SchoolCollection), schoolContext.GetType());
    }
}
where TypeService is static class, and Services is static property of IResolvable type (interface is provided by Library).
Services property:
/// <summary>
    /// The resolvable.
    /// </summary>
    private static IResolvable resolvable;
    /// <summary>
    /// Gets the type services.
    /// </summary>
    public static IResolvable Services
    {
        get
        {
            if (resolvable == null)
            {
                var builder = new ContainerBuilder();
                builder.Register();
                resolvable = builder.Build();
            }
            return resolvable;
        }
    }