我想在我的.NET WPF桌面应用程序中实现Firebase.我在互联网上找不到有关这个主题的任何有用信息,似乎它完全不受支持.只有一个Xamarin NuGet包.有没有可能这样做?目标是为用户在应用程序中执行的多项操作实施Firebas Analytics.如果我能找到它们,我甚至会采用正常的REST端点 - 它们隐藏在某个地方......
是否可以在.NET 4.5.2项目中引用.NET Core库?我正在使用最新的.NET Core,并希望为我的WPF项目和我的.NET Core Web API使用相同的库.如果我想添加对项目的引用,则会显示以下窗口:
我还尝试将我的WPF项目升级到4.6.1但这并没有改变任何东西.
更新
现在可以使用Core 2.0
我有一个班负责在下载管理器中下载文件.该类负责下载文件并将其写入给定路径.
要下载的文件大小通常在1到5 MB之间变化,但也可能更大.我正在使用WebClient类的实例从Internet获取文件.
public class DownloadItem
{
#region Events
public delegate void DownloadItemDownloadCompletedEventHandler(object sender, DownloadCompletedEventArgs args);
public event DownloadItemDownloadCompletedEventHandler DownloadItemDownloadCompleted;
protected virtual void OnDownloadItemDownloadCompleted(DownloadCompletedEventArgs e)
{
DownloadItemDownloadCompleted?.Invoke(this, e);
}
public delegate void DownloadItemDownloadProgressChangedEventHandler(object sender, DownloadProgressChangedEventArgs args);
public event DownloadItemDownloadProgressChangedEventHandler DownloadItemDownloadProgressChanged;
protected virtual void OnDownloadItemDownloadProgressChanged(DownloadProgressChangedEventArgs e)
{
DownloadItemDownloadProgressChanged?.Invoke(this, e);
}
#endregion
#region Fields
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private WebClient _client;
#endregion
#region Properties
public PlaylistItem Item { get; }
public string SavePath { get; }
public bool Overwrite …Run Code Online (Sandbox Code Playgroud) 目标是一个Web应用程序,它与安装在用户PC上的C#应用程序交换信息.客户端应用程序是websocket服务器,浏览器是websocket客户端.
最后,用户浏览器中的websocket客户端通过Angular持久创建,应用程序在PC上运行并执行某些操作.
使用的C#库是WebSocket-Sharp.websocket客户端是普通的javascript.
显然,此连接仅在本地发生,因此客户端连接到localhost.由于网站是通过HTTPS保护的,因此websocket也必须得到保护.为此,C#应用程序在启动时创建证书(实际上仅用于测试目的).
连接不起作用,因为证书不受信任.禁用客户端的所有服务器检查,但不建立连接.
这是创建服务器的部分
_server = new WebSocketServer($"wss://localhost:4649")
{
SslConfiguration =
{
ServerCertificate = Utils.Certificate.CreateSelfSignedCert(),
ClientCertificateRequired = false,
CheckCertificateRevocation = false,
ClientCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true
}
};
_server.AddWebSocketService<CommandsBehaviour>("/commands");
_server.AddWebSocketService<NotificationsBehaviour>("/notifications");
_server.Start();
Run Code Online (Sandbox Code Playgroud)
这是使用BouncyCastle创建证书的方式
private static AsymmetricKeyParameter CreatePrivateKey(string subjectName = "CN=root")
{
const int keyStrength = 2048;
// Generating Random Numbers
var randomGenerator = new CryptoApiRandomGenerator();
var random = new SecureRandom(randomGenerator);
// The Certificate Generator
var certificateGenerator = new X509V3CertificateGenerator();
// Serial Number
var serialNumber …Run Code Online (Sandbox Code Playgroud) 我的子路由组件正在查询API中的一些数据.目前我正在检查组件,如果通过检查API返回的数据,作为路由参数提供的id是有效的.
我认为这是一种糟糕的风格,并希望将检查放入一个警卫,在组件被激活之前检查提供的参数是否有效.
但是,我也想节省时间和资源.这将需要两个API请求.因此,我想知道是否有可能将数据从防护装置传递给组件.我想过传递路线参数,但canActivate只提供一个ActivatedRouteSnapshot只读的.
因此我的问题是:是否可以将数据从防护组件传递到组件?或者在这种情况下是否有另一种(甚至更好的)方法来节省资源并防止多个API请求?
我有这个数组:
{
"AssemblyVersion":"0.1.333.5973",
"Exception":
{
// [...]
}
}
Run Code Online (Sandbox Code Playgroud)
它是从此类序列化的:
public class ErrorData
{
public string AssemblyVersion { get; private set; }
public Exception Exception { get; private set; }
public ErrorData(string assemblyVersion, Exception ex)
{
AssemblyVersion = assemblyVersion;
Exception = ex;
}
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
Run Code Online (Sandbox Code Playgroud)
将其序列化回对象会产生以下异常:
Newtonsoft.Json.JsonReaderException: Input string '0.1.335.5973' is not a valid number. Path 'AssemblyVersion', line 1, position 29.
at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract …Run Code Online (Sandbox Code Playgroud) 我想将MahApps库中的图标放入普通按钮.我这样试过:
<Button Height="20" Width="25" Background="Transparent" Foreground="White" Content="{StaticResource appbar_close}"/>
Run Code Online (Sandbox Code Playgroud)
结尾如下:
那么如何在适当的位置将此图标集成到此按钮中?
我有一个托管在 GitHub 上并附加到 Travis 的 WPF C# 应用程序。我这样配置我的 .travis-ci.yml :
language: csharp
solution: FaceDetection/FaceDetection.sln
script:
- xbuild /p:Configuration=Debug /p:Platform=x86 /p:TargetFrameworkVersion="v4.0" FaceDetection/FaceDetection.sln
Run Code Online (Sandbox Code Playgroud)
但是,当 travis 即将编译该项目时,我收到这些错误:
/usr/lib/mono/4.5/Microsoft.Common.targets: warning : Reference 'PresentationCore' not resolved
/usr/lib/mono/4.5/Microsoft.Common.targets: warning : Reference 'PresentationFramework' not resolved
Run Code Online (Sandbox Code Playgroud)
在我的 Windows 机器上的 VS 本地编译项目工作正常。因此,我包含了该项目所需的所有参考资料。
这也发生在其他一些参考文献上:
Views/Converters/BitmapConverter.cs(5,28): error CS0234: The type or namespace name `Imaging' does not exist in the namespace `System.Windows.Media'. Are you missing an assembly reference?
Views/UserControls/FaceDatabaseEntry.xaml.cs(7,22): error CS0234: The type or namespace name `Controls' does not exist in the …Run Code Online (Sandbox Code Playgroud) 假设我有项目A和项目B。在相同的解决方案中有它们,并且A引用B并将B用作一种从属进程。我不想对B的程序集名称进行硬编码,但我想知道如何在项目A中查询程序集名称,以便可以执行项目B的程序集。