简体   繁体   中英

Troubles making PCL Xamarin (MonoDroid/MonoTouch) compliant

We've created a fairly robust PCL that we'd like to use in some Droid/Touch apps via Xamarin.

As of today, I've installed the latest version of Xamarin, and I've set our PCL to use Profile 158 .

I've then gone into our project and updated the target assemblies

  • .NET Framework 4.5
  • Windows Phone 8
  • .NET for Windows Store apps
  • Xamarin.Android
  • Xamarin.iOS

After doing that, I'm getting a number of Compilation Failures

编译错误
full size image here

Do I need to replace the System dll with the one that ships with Xamarin, or is there something else I need to do in order to get this stuff working?

note: if I wasn't clear above, there was nothing wrong with the PCL before adding Xamarin targets.


As requested, here's the build output

1>------ Build started: Project: MyApplication.AppCore, Configuration: Debug Any CPU ------
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(25,29,25,61): error CS1502: The best overloaded method match for 'MyApplication.AppCore.Data.DbProviderExtensions.GetTableName(System.Reflection.MemberInfo)' has some invalid arguments
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(25,43,25,57): error CS1503: Argument 1: cannot convert from 'System.Type' to 'System.Reflection.MemberInfo'
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(53,29,53,61): error CS1502: The best overloaded method match for 'MyApplication.AppCore.Data.DbProviderExtensions.GetTableName(System.Reflection.MemberInfo)' has some invalid arguments
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(53,43,53,57): error CS1503: Argument 1: cannot convert from 'System.Type' to 'System.Reflection.MemberInfo'
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(55,38,55,71): error CS1502: The best overloaded method match for 'MyApplication.AppCore.Data.DbProviderExtensions.GetTableName(System.Reflection.MemberInfo)' has some invalid arguments
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(55,52,55,67): error CS1503: Argument 1: cannot convert from 'System.Type' to 'System.Reflection.MemberInfo'
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(85,29,85,61): error CS1502: The best overloaded method match for 'MyApplication.AppCore.Data.DbProviderExtensions.GetTableName(System.Reflection.MemberInfo)' has some invalid arguments
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(85,43,85,57): error CS1503: Argument 1: cannot convert from 'System.Type' to 'System.Reflection.MemberInfo'
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(102,29,102,61): error CS1502: The best overloaded method match for 'MyApplication.AppCore.Data.DbProviderExtensions.GetTableName(System.Reflection.MemberInfo)' has some invalid arguments
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(102,43,102,57): error CS1503: Argument 1: cannot convert from 'System.Type' to 'System.Reflection.MemberInfo'
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(120,29,120,61): error CS1502: The best overloaded method match for 'MyApplication.AppCore.Data.DbProviderExtensions.GetTableName(System.Reflection.MemberInfo)' has some invalid arguments
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(120,43,120,57): error CS1503: Argument 1: cannot convert from 'System.Type' to 'System.Reflection.MemberInfo'
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(144,29,144,61): error CS1502: The best overloaded method match for 'MyApplication.AppCore.Data.DbProviderExtensions.GetTableName(System.Reflection.MemberInfo)' has some invalid arguments
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(144,43,144,57): error CS1503: Argument 1: cannot convert from 'System.Type' to 'System.Reflection.MemberInfo'
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(171,41,171,54): error CS1061: 'System.Type' does not contain a definition for 'GetProperties' and no extension method 'GetProperties' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Data\DbProviderExtensions.cs(239,25,239,38): error CS1061: 'System.Type' does not contain a definition for 'GetInterfaces' and no extension method 'GetInterfaces' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Infrastructure\AutoMapper.cs(18,54,18,67): error CS1061: 'System.Type' does not contain a definition for 'GetProperties' and no extension method 'GetProperties' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Infrastructure\AutoMapper.cs(47,54,47,67): error CS1061: 'System.Type' does not contain a definition for 'GetProperties' and no extension method 'GetProperties' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Infrastructure\AutoMapper.cs(78,50,78,63): error CS1061: 'System.Type' does not contain a definition for 'GetProperties' and no extension method 'GetProperties' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Infrastructure\AutoMapper.cs(100,50,100,63): error CS1061: 'System.Type' does not contain a definition for 'GetProperties' and no extension method 'GetProperties' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Infrastructure\MigrationRunner.cs(61,40,61,48): error CS1061: 'System.Type' does not contain a definition for 'Assembly' and no extension method 'Assembly' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Infrastructure\MigrationRunner.cs(62,77,62,93): error CS1061: 'System.Type' does not contain a definition for 'IsAssignableFrom' and no extension method 'IsAssignableFrom' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)
1>P:\MyApplication.AppCore\MyApplication.AppCore\Repositories\RepositoryBase.cs(60,30,60,50): error CS0117: 'System.Reflection.Assembly' does not contain a definition for 'GetExecutingAssembly'
2>------ Build started: Project: MyApplication.AppCore.Tests, Configuration: Debug Any CPU ------
2>  P:\MyApplication.AppCore\MyApplication.AppCore.Tests\x86\sqlite3.dll
2>  1 File(s) copied
2>  P:\MyApplication.AppCore\MyApplication.AppCore.Tests\x64\sqlite3.dll
2>  1 File(s) copied
2>  MyApplication.AppCore.Tests -> P:\MyApplication.AppCore\MyApplication.AppCore.Tests\bin\Debug\MyApplication.AppCore.Tests.dll
========== Build: 1 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========

Not sure if seeing some lines of code will help but, here goes

    public static void Create<TModel> ( this IDbProvider dbProvider, TModel model ) where TModel : class, new()
    {

        var tableName = GetTableName( typeof( TModel ) ); // LINE 25

    }
foreach ( 
    var collection in model.GetType()
                           .GetProperties() // LINE 171
                           .Where(
                               property =>
                               property.GetCustomAttributes( typeof( ManyToManyAttribute ), true ).Any() ) )
{
        if ( !IsGenericList( collection.PropertyType ) )  // LINE 176
            throw new ArgumentException( "The property must be an ICollection<>" );
}
    private static bool IsGenericList ( Type type )
    {
        if ( type == null )
            throw new ArgumentNullException( "type" );

        return type.GetInterfaces() // LINE 239
                   .Where( i => i.IsGenericType )
                   .Any( i => i.GetGenericTypeDefinition() == typeof( ICollection<> ) );
    }

Profile158 targets Silverlight 5 in addition to the other targets you listed. What profile were you targeting before you added Xamarin support?

One thing to try is to target Profile78, which should be the set of platforms you listed.

If that doesn't work, can you update your answer with the errors copied from the build output? The errors in the screenshot are hard to read and it's not clear if they are all coming from the same project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM