簡體   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