我正在为Winforms创建一个应用程序。我计划稍后为Windows Phone发布此应用程序。所以我决定使用Portable库。我有以下可移植库的Target框架:
.NET Framework 4 and higher
Silverlight 4 and higher
Windows Phone 7 and higher
.NET for Windows Store apps
在我的便携式库中,我引用了以下来自Google驱动程序SDK的库:
DotNetOpenAuth.dll
Google.Apis.Authentication.OAuth2.dll
Google.Apis.dll
Google.Apis.Drive.V2.dll
Google.Apis.OAuth2.V2.dll
log4net.dll
Newtonsoft.Json.Net35.dll
直到现在我构建我的解决方案时,它工作正常,因为我在任何地方都有这些引用。但是当我在我的代码中使用这些引用时:
using Google.Apis.Authentication;
using File = Google.Apis.Drive.v2.Data.File;
public interface IUtilities
{
void SampleMethod(IAuthenticator authenticator, File file);
}
现在,我没有编译错误。但是,当我尝试构建解决方案时,我得到了
Error 1 The type or namespace name 'IAuthenticator' could not be found (are you missing a using directive or an assembly reference?)
Error 3 The type or namespace name 'Google' could not be found (are you missing a using directive or an assembly reference?)
如果我使用这些库编写更多代码,我会以类似的方式获取所有这些对象的错误。任何人都可以帮我理解这个吗?如果您需要更多信息,请告诉我。感谢。
答案 0 :(得分:3)
您从可移植类库中引用的任何库也必须是可移植的(并且支持兼容的平台)。 Json.NET有一个可移植版本,但你使用的其他库可能没有。您可以将源代码获取到这些库并将它们移植到PCL,或者您可以为它们提供的功能创建可移植的抽象,并使用这些抽象来允许您调用特定于平台的代码。
以下是有关使用可移植类库的更多信息的一些来源: