我正在编写一个C#应用程序来解码这个字符串:
"--W3sic3RhcnRfdGltZSI6IjAiLCJwcm9kdWN0X2lkIjoiODQwMDMzMDQiLCJ1cmwiOiIifSx7InN0YXJ0X3RpbWUiOiI3OSIsInByb2R1Y3RfaWQiOiI4NDAzNjk2MSIsInVybCI6IiJ9LHsic3RhcnRfdGltZSI6IjgyIiwicHJvZHVjdF9pZCI6Ijg0MDAzMDIwIiwidXJsIjoiIn0seyJzdGFydF90aW1lIjoiMTA5IiwicHJvZHVjdF9pZCI6IiIsInVybCI6Imh0dHBzOi8vYmxvZy5sYXJlaW5lZHVzaG9wcGluZy5jYS8yMDE3LzAxL3RyYW5zZm9ybWVyLXNlcy12aWV1eC1nYW50cy1kZS1jdWlyLWVuLTUtbWludXRlcy8ifV0 ="
当我将其复制/粘贴到此在线工具中时,它可以工作:https://www.base64decode.org
但是当我使用它时抛出一个异常Convert.FromBase64String(str)
:
System.FormatException:输入不是有效的Base-64字符串,因为它包含非基本64个字符,两个以上的填充字符或填充字符中的非法字符.
为什么?
在我的WPF应用程序中,我有一个在我的UI元素的MouseEnter事件上调用的事件处理程序:
myUiElement.MouseEnter += myEventHandler
Run Code Online (Sandbox Code Playgroud)
我想限制myEventHandler,所以它不会每秒被调用多次.我怎样才能做到这一点?Rx是最好的方法吗?如果它有所作为,我正在使用.NET 4.0.
此外,我需要确保在下一个MouseEnter事件之前始终调用MouseLeave事件; 我需要自己管理吗?或者框架是否已经设计好,以便在下一个MouseEnter事件之前始终调用MouseLeave事件?如果我在这些事件处理程序中有异步代码怎么办?
我正在使用CLR内存诊断库来获取正在运行的进程中所有线程的堆栈跟踪:
var result = new Dictionary<int, string[]>();
var pid = Process.GetCurrentProcess().Id;
using (var dataTarget = DataTarget.AttachToProcess(pid, 5000, AttachFlag.Passive))
{
string dacLocation = dataTarget.ClrVersions[0].TryGetDacLocation();
var runtime = dataTarget.CreateRuntime(dacLocation); //throws exception
foreach (var t in runtime.Threads)
{
result.Add(
t.ManagedThreadId,
t.StackTrace.Select(f =>
{
if (f.Method != null)
{
return f.Method.Type.Name + "." + f.Method.Name;
}
return null;
}).ToArray()
);
}
}
Run Code Online (Sandbox Code Playgroud)
我从这里得到这个代码,它似乎适用于其他人,但它在指定的行上抛出了一个异常,带有消息This runtime is not initialized and contains no data.
dacLocation
被设为 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscordacwks.dll
我正在使用Xamarin开发Apple Watch应用程序.我试图用我的SendMessage
功能从我的手表向iPhone发送消息.当我这样做时,我收到out
错误消息payload could not be delivered
.我只能读取部分消息("有效负载可能......")因为我在标签上写它(因为我的调试器在Xamarin中不起作用我不能看一下消息),但之后做一些谷歌搜索我假设这是它写的.知道为什么吗?这是我的代码:
public sealed class WCSessionManager : NSObject, IWCSessionDelegate
{
// Setup is converted from https://www.natashatherobot.com/watchconnectivity-say-hello-to-wcsession/
// with some extra bits
private static readonly WCSessionManager sharedManager = new WCSessionManager();
private static WCSession session = WCSession.IsSupported ? WCSession.DefaultSession : null;
#if __IOS__
public static string Device = "Phone";
#else
public static string Device = "Watch";
#endif
public event ApplicationContextUpdatedHandler ApplicationContextUpdated;
public delegate void ApplicationContextUpdatedHandler(WCSession session, Dictionary<string, object> applicationContext);
public event MessageReceivedHandler …
Run Code Online (Sandbox Code Playgroud) 我是Docker的新手.我正在Docker环境中开发一个PHP应用程序,我需要使用MySql Server /数据库来保存数据.下面的文档,我运行此命令来创建MySql服务器映像:
docker run -v /var/lib/mysql mariadb
它下载了它,但我也用这个错误:
错误:数据库未初始化且未指定密码选项您需要指定MYSQL_ROOT_PASSWORD,MYSQL_ALLOW_EMPTY_PASSWORD和MYSQL_RANDOM_ROOT_PASSWORD之一
如何设置MYSQL_ALLOW_EMPTY_PASSWORD选项?
然后我如何在这个图像上创建一个数据库,然后从我的PHP代码(在不同的图像上)读/写它?
我想在我的Xamarin.Android项目中使用这个.jar文件:
https://drive.google.com/file/d/0B8xKHTqtwfKtdzVtdDQ5NEVIWlU/view?usp=sharing
在我创建绑定项目并尝试构建之后,我收到此错误:
obj\Debug\generated\src\Com.Acrcloud.Rec.Sdk.Utils.ACRCloudGetIPAddressAsyncTask.cs(23,23): Error CS0534: 'ACRCloudGetIPAddressAsyncTask' does not implement inherited abstract member 'AsyncTask.DoInBackground(params Object[])' (CS0534)
使用反编译器,我检查了内容,ACRCloudGetIPAddressAsyncTask
发现了这个:
package com.acrcloud.rec.sdk.utils;
import android.os.AsyncTask;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class ACRCloudGetIPAddressAsyncTask
extends AsyncTask<String, Integer, String>
{
private static final String TAG = "ACRCloudAsynGetIPAddressTask";
protected String doInBackground(String... params)
{
String ip = "";
try
{
InetAddress x = InetAddress.getByName(params[0]);
ip = x.getHostAddress();
}
catch (UnknownHostException e)
{
e.printStackTrace();
ip = "";
}
catch (Exception e2)
{
ip = "";
}
return ip; …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Xamarin.Android 编写一个 Android 应用程序,但是本机 Android 中的答案也将受到赞赏。在我的 Android 应用程序中,我有一个设备可以写入的 BLE 写入特性。它可以工作,但我无法发送超过 20 个字节,其余的会被切断。我用于创建和添加服务/特性的代码:
BluetoothGattService service = new BluetoothGattService(Java.Util.UUID.FromString(MyServiceUuid), GattServiceType.Primary);
// write characteristic (write-only, supports subscriptions)
BluetoothGattCharacteristic writeCharacteristic = new BluetoothGattCharacteristic(Java.Util.UUID.FromString(MyCharacteristicUuid), GattProperty.WriteNoResponse | GattProperty.Notify, GattPermission.Write);
service.AddCharacteristic(writeCharacteristic);
_bluetoothGattServer.AddService(service);
Run Code Online (Sandbox Code Playgroud)
我在写入特征的一侧的代码:
public override void OnServicesDiscovered(BluetoothGatt gatt, [GeneratedEnum] GattStatus status)
{
base.OnServicesDiscovered(gatt, status);
characteristic = gatt.GetService(Java.Util.UUID.FromString(MyServiceUuid))
.GetCharacteristic(Java.Util.UUID.FromString(MyCharacteristicUuid));
if(characteristic.Properties.HasFlag(GattProperty.WriteNoResponse))
{
Log?.Invoke("writing characteristic...");
characteristic.SetValue(MyVeryLongString);
characteristic.WriteType = GattWriteType.NoResponse;
gatt.WriteCharacteristic(characteristic);
}
}
Run Code Online (Sandbox Code Playgroud)
在接受写入请求的一侧:
public override void OnCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, bool preparedWrite, bool responseNeeded, int offset, byte[] …
Run Code Online (Sandbox Code Playgroud) 如何检查enum
是否标记为过时?
public enum MyEnums
{
MyEnum1,
[Obsolete("How can you know that I'm obsolete?")]
MyEnum2,
MyEnum3
}
Run Code Online (Sandbox Code Playgroud)
现在在运行时,我需要知道哪些是过时的:
foreach (var myEnum in Enum.GetValues(typeof(MyEnums)).Cast<MyEnums>())
{
// How can I check if myEnum is obsolete?
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的OpenGL程序中实现实例化.我让它工作,然后决定通过将模型 - 视图 - 投影乘法矩阵作为GLSL程序的输入来使我的GLSL代码更有效,以便CPU为每个实例计算它,而不是GPU.这是我的顶点着色器代码(大部分与我的问题无关):
#version 330 core
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 2) in vec3 vertexColor;
layout(location = 3) in vec3 vertexNormal_modelspace;
layout(location = 6) in mat4 models;
layout(location = 10) in mat4 modelsV;
layout(location = 14) in mat4 modelsVP;
// Output data ; will be interpolated for each fragment.
out vec3 newColor;
out vec3 Position_worldspace;
out vec3 Normal_cameraspace;
out vec3 EyeDirection_cameraspace;
// Values that …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Xamarin iOS,并且我有一个Localizable.strings
文件,用于保存所有字符串。现在它变得非常混乱,想知道是否有办法在此文件中添加注释以更好地组织它?