2013-11-14 30 views
4

我們已經創建了一個相當強大的PCL,我們希望通過Xamarin在某些Droid/Touch應用程序中使用。製造PCL的麻煩Xamarin(MonoDroid/MonoTouch)兼容

截至今天,我已經安裝了最新版本的Xamarin,並且我已將PCL設置爲use Profile 158

我則進入了我們的項目,並更新了靶組件

  • .NET框架4.5
  • 的Windows Phone 8
  • .NET的Windows Store應用程序
  • Xamarin.Android
  • Xamarin.iOS

這樣做後,我得到了一些編譯錯誤的

compilation errors
full size image here

我是否需要更換System DLL與一個附帶Xamarin,還是有別的東西我需要這樣做才能讓這些東西起作用?

注意:如果我上面不清楚,在添加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<>)); 
    } 
+0

它迫使你使用新的Reflection API? – atomaras

+0

@atomaras我不知道有一個新的Reflection API。 –

+0

請在* DbProviderExtensions.cs *中顯示一些代碼,例如圍繞第25,171和239行。 –

回答

0

Profile158除了列出的其他目標外,還以Silverlight 5爲目標。在添加Xamarin支持之前,您定位了哪些配置文件?

要做的一件事就是定位Profile78,它應該是您列出的平臺的集合。

如果這不起作用,您能否更新您的答案和從構建輸出中複製的錯誤?屏幕截圖中的錯誤很難閱讀,但不清楚它們是否都來自同一個項目。

+0

之前的個人資料是104.所有的錯誤都來自同一個項目,截圖下面有一個鏈接到完整大小的圖片。 –

+0

我已更新您所需的信息。 –

+0

@ChaseFlorell你可以嘗試改回到Profile104,看看它是否仍然編譯成功?此外,PCL不應該有任何明確的引用.NET Framework程序集,如System.DLL或mscorlib,所以如果你的項目中有任何這些程序,請嘗試刪除它們。 –