我可以使用 Type.IsValueType 在 .net 4.5 中以一种直接的方式解决这个问题,但是当我使用便携式库创建通用应用程序时,它没有任何等效的方法来查找类型是否为值。
有没有其他技巧可以找到这个?
当我尝试在Xamarin.Forms上创建新标签时,我收到以下警告:
about = new Label { Text = "" ,
TextColor=Color.Black,
Font = Font.SystemFontOfSize(16),//Warning occurred here
XAlign = TextAlignment.End,
HorizontalOptions = LayoutOptions.EndAndExpand};
Run Code Online (Sandbox Code Playgroud)
'Xamarin.Forms.Label.Font' 已过时:'请使用类本身的字体属性。在 v1.3.0 中已废弃'
这个警告意味着什么,我应该怎么做?
我正在努力使用 Xamarin 和 BouncyCastle 创建 pfx 文件。我有以下设置/规范
我想为我的移动客户端生成一个自签名证书,以便根据我的服务器对其进行身份验证。使用 BouncyCastle 进行创作效果非常好。我的问题是,当我想将证书及其私钥存储为 PKCS#12 (pfx) 容器并从该容器恢复它以发送由它签名的 Web 请求时,会抛出异常告诉我Input data cannot be coded as a valide certificate。
以下是我创建证书、密钥和存储 pfx 容器的步骤。
创建密钥对:
private AsymmetricCipherKeyPair GenerateKeyPair()
{
var random = new SecureRandom();
var keyGenerationParameter = new KeyGenerationParameters(random, 4096);
var keyPairGenerator = new RsaKeyPairGenerator();
keyPairGenerator.Init(keyGenerationParameter);
var keyPair = keyPairGenerator.GenerateKeyPair();
return keyPair;
}
Run Code Online (Sandbox Code Playgroud)
创建证书,它将调用创建密钥并创建容器:
public void CreateCertificate()
{
var random = new SecureRandom();
var keyPair …Run Code Online (Sandbox Code Playgroud) 这非常令人沮丧,我有一个可移植类库(PCL)库,它必须在配置文件中删除.NET 4.0才能访问正确的API"在PCL中".但是,这些API确实存在于.NET 4.0中,因此如果完全相同的代码在.NET 4.0项目中,则编译就可以了.
我想要一个最小的持续维护方法来重新编译这个PCL项目中的代码到.net 4.0,所以我可以将它包含在Nuget包中.
我试图让我的pcl正确构建到nuget包中.我已更新到xamarin测试版,我已将nuget更新到版本2.8.5但是在创建我的软件包时出现以下错误:
问题:无效的框架文件夹.
说明:"lib"下的"Xamarin.iOS10"文件夹无法识别为有效的框架名称或支持的区域性标识符.
解决方案:将其重命名为有效的框架名称.
如果我只是使用MonoTouch我没有得到错误,坚果然后nuget包没有正确安装.
我希望编写一个可以在许多目标上运行的库,例如WPF,Windows Phone/Mobile,Mono和ASP.NET.我一直在寻找有关这方面的信息,但似乎在ASP.NET中不支持PCL?
甚至VS表示PCL不能与ASP.NET一起使用:

那么我该怎么做才能编写一个在所有平台上运行的PCL呢?将PCL用于除ASP.NET之外的所有内容,并为ASP.NET创建一个普通的类库,并基本上复制+粘贴代码?
我正在构建一个带有便携式类库的Android/iOS xamarin表单应用程序.我正在寻找在PCL项目中执行此示例的最佳方法:
https://msdn.microsoft.com/en-us/library/456dfw4f(v=vs.110).aspx
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main ()
{
// Create a request for the URL.
WebRequest request = WebRequest.Create (
"http://www.contoso.com/default.html");
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();
// Open …Run Code Online (Sandbox Code Playgroud) httpwebrequest portable-class-library dotnet-httpclient xamarin xamarin.forms
我可能在这里真的很愚蠢。
我已经更新了解决方案,可以开始使用.NET 4.6。我的PCL项目之一对枚举进行了一些反思。我已经更新了PCL兼容性,并修复了它创建的空project.json文件。但是,此PCL项目不再生成,因为无法识别Type.GetMember()或MemberInfo[x].GetCustomAttribute(...)
我一直在使用并且一直工作到今天的代码是:
MemberInfo[] info = e.GetType().GetMember(e.ToString());
if (info != null && info.Length > 0)
{
object[] attributes = info[0].GetCustomAttributes(typeof(Description), false);
if (attributes != null && attributes.Length > 0)
return ((Description)attributes[0]).Text;
}
return e.ToString();
Run Code Online (Sandbox Code Playgroud)
该项目仅引用以下路径中的.NET库:
C:\ Program Files(x86)\ Reference Assemblys \ Microsoft \ Framework.NETPortable \ v4.5 \ Profile \ Profile7 \
作为PCL配置的一部分,该项目也自动支持Xamarin平台。
任何想法将不胜感激。
我目前正在开发一个.NET Core库,我将在另一个项目中用作NuGet包.
我已经能够使用项目目录中的"dotnet pack"命令成功打包项目,并将该程序包上传到MyGet.
我更喜欢使用"nuget push"命令自动执行推送NuGet包的过程.
我的问题是project.json文件中定义的"scripts"属性似乎不在包或构建上执行.我预计这些脚本会在相应的事件发生时执行,但它们似乎没有任何效果,因为我在构建时没有看到任何输出到控制台,无论是否有详细标记.
我知道MyGet能够基于Git存储库更新包源,但我想了解当前使用project.json执行脚本是否存在一些问题.理想情况下,我想在pack成功执行后使用nuget push命令.
这是我的project.json文件:
{
"version": "0.0.1",
"scripts": {
"postbuild": [ "echo build" ],
"prebuild": "echo build",
"postpack": "echo build",
"postpublish": "echo build",
"postrestore": "echo build",
"prepack": "echo build",
"prepare": "echo build",
"prepublish": "echo build",
"prerestore": "echo build"
},
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027"
},
"frameworks": {
"netstandard1.5": {
}
},
"buildOptions": {
"allowUnsafe": false,
"debugType": "portable",
"emitEntryPoint": false,
"xmlDoc": false
},
"commands": { },
"packOptions": {
"files": {
"include": "%project:Directory%/bin/release/*.nupkg"
}
},
"configurations": { …Run Code Online (Sandbox Code Playgroud) scripting nuget portable-class-library project.json asp.net-core
我试图从PCL项目中获取文件PCLStorage,如下所示.我在Visual Studio 2015 Professional中使用Xamarin.
IFile file = await FileSystem.Current.GetFileFromPathAsync("file\path");
Run Code Online (Sandbox Code Playgroud)
但我得到例外:
System.NotImplementedException:此程序集的可移植版本中未实现此功能.您应该从主应用程序项目中引用PCLStorage NuGet包,以引用特定于平台的实现.
c# ×5
xamarin ×5
.net ×3
nuget ×2
.net-4.0 ×1
.net-4.5 ×1
asp.net-core ×1
asp.net-mvc ×1
bouncycastle ×1
mono ×1
msbuild ×1
project.json ×1
scripting ×1
wpf ×1