繁体   English   中英

麻烦使PCL Xamarin(MonoDroid / MonoTouch)兼容

[英]Troubles making PCL Xamarin (MonoDroid/MonoTouch) compliant

我们已经创建了一个相当强大的PCL,我们希望通过Xamarin在一些Droid / Touch应用程序中使用它。

截至今天,我已经安装了最新版本的Xamarin,并且我已经将我们的PCL设置为使用Profile 158

然后我进入了我们的项目并更新了目标组件

  • .NET Framework 4.5
  • Windows Phone 8
  • .NET for Windows Store应用程序
  • Xamarin.Android
  • Xamarin.iOS

在这之后,我得到了许多编译失败

编译错误
全尺寸图片在这里

我是否需要将System dll替换为Xamarin附带的System dll,或者我需要做些什么来使这些东西工作?

注意:如果我上面不清楚,在添加Xamarin目标之前PCL没有任何问题。


根据要求,这是构建输出

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 ==========

不确定是否看到一些代码行会有所帮助,但是,这里有

    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还针对Silverlight 5。 在添加Xamarin支持之前,您的目标是什么?

要尝试的一件事是定位Profile78,它应该是您列出的平台集。

如果这不起作用,您可以使用从构建输出中复制的错误更新您的答案吗? 屏幕截图中的错误很难阅读,并且不清楚它们是否都来自同一个项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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