我发现Xamarin Forms XAML非常令人沮丧.
如果我使用这种语法......
<ContentView.Resources>
<local:MyConverter1 x:Key="MyConverter1"/>
</ContentView.Resources>
Run Code Online (Sandbox Code Playgroud)
我将从InitializeComponent()获得System.NullReferenceException.堆栈跟踪或输出窗口或其他任何地方都没有告诉我什么是错的.注意:此语法在WPF中正常工作.
经过很多努力,我发现我需要这种语法......
<ContentView.Resources>
<ResourceDictionary>
<local:MyConverter1 x:Key="MyConverter1"/>
</ResourceDictionary>
</ContentView.Resources>
Run Code Online (Sandbox Code Playgroud)
同样适用于ListView DataTemplate.抛出null引用异常......
<ListView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Converter={StaticResource MyConverter1}}"/>
</DataTemplate>
</ListView.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
因为正确的语法是这个......
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding Converter={StaticResource MyConverter1}}"/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
再次,这种语法在WPF中工作正常.我完全意识到Xamarin Forms不是WPF,但每当我使用在WPF中有效的XAML构造时,我都会厌倦被空引用异常打孔.
调试Xamarin Forms XAML问题的最佳方法是什么?现在我只是简单地评论它,直到它开始工作.这类似于将打印语句放入命令式代码中.声明性代码应该优于命令式代码.我究竟做错了什么?
在Windows docker容器中运行ASP.NET Core时出现此错误...
Unhandled Exception: System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.
Run Code Online (Sandbox Code Playgroud)
我能够使它工作...
RUN dotnet dev-certs https
Run Code Online (Sandbox Code Playgroud)
但是我想安装一个实际的证书...现在是一个自签名证书,但后来却是一个真正的证书。
因此,基于一篇名为“使用Powershell导入和绑定Windows容器中的SSL证书”的博客文章,我创建了以下PS脚本以在容器构建中运行...
Import-PfxCertificate -FilePath C:\Certificates\xxx.pfx -Password (ConvertTo-SecureString -String "xxxx" -AsPlainText -Force) `
-CertStoreLocation "Cert:\LocalMachine\My"
$cert = (Get-ChildItem -Path cert:\LocalMachine\My -DNSName "xxx.mydomain.com")[0]
$thumb = ($cert | Select-Object Thumbprint)."Thumbprint"
$guid = [guid]::NewGuid().ToString("B")
netsh http add sslcert ipport=0.0.0.0:5001 certhash=$thumb certstorename=MY appid="$guid"
Run Code Online (Sandbox Code Playgroud)
这样可以构建良好,并且似乎可以安装证书。但是当我尝试运行容器时出现异常。我尝试使用443而不是5001,出现同样的错误
这是我的docker文件供参考...
escape=`
FROM xxx/base
EXPOSE 5000
EXPOSE 5001
COPY testing/ /testing …Run Code Online (Sandbox Code Playgroud) 我正在尝试从主机解析 docker 容器地址。Windows 主机。Windows 容器。我回顾了许多类似的问题:
这些问题都没有解决这个具体问题。看起来像是一个微不足道的操作,我根本不明白为什么它不起作用。
例如
$ docker network create -d nat --subnet 172.25.0.0/16 test-net
$ docker container run --network test-net --name example-1 test/example1
Run Code Online (Sandbox Code Playgroud)
其中 test/example1 只是一个 ASP.NET Core Web 服务器。
因此,在我看来,我应该能够根据我在上面引用的答案中看到的各种线索来解析主机的容器名称。例如
$ nslookup example-1 172.25.0.1
$ nslookup example-1 127.0.0.11
$ nslookup example-1.test-net.docker 127.0.0.11
Run Code Online (Sandbox Code Playgroud)
然而没有任何作用。
当然,我在生产中不需要这种功能,但它对于测试非常有帮助。我根本不明白为什么我不能让它发挥作用。我缺少什么?
我在 VS android 模拟器和 Android 硬件设备上从 expo 连接到 react-native 打包程序时遇到 Windows 防火墙问题。
我在 Expo 中遇到的错误是“未捕获错误:Packager 未在 http://192.168.1.8:19001 运行”。
这不是您在使用 Expo 时遇到的常见连接问题,如无法加载 exp:// 出了问题中所述。我已经躺在那张痛苦的床上了。我现在的环境变量设置如下......
set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.8
Run Code Online (Sandbox Code Playgroud)
这是全新的事情。直到上次 Windows 更新之前一切都运行良好。我知道这是 Windows 防火墙问题的原因是,当我关闭防火墙时,一切都会开始工作。
但这不是解决办法。我真的很想重新打开防火墙。我查看了防火墙规则,在入站规则中看到了 Expo XDE 和 Node.js。
真正的解决办法是什么?我感觉很多人突然都遇到了这个问题。
我发现我的 Windows 10 机器上有许多端口,它们 (1) 没有被任何进程使用,并且 (2) 我无法监听。
我在尝试运行使用端口 3000 的节点服务器时发现了这个问题。我发现了许多关于这个主题的问题。这是典型的: Node.js 端口 3000 已在使用中,但实际上并未使用?
这个问题和类似问题的所有受访者都建议使用“netstat -ano”来查找正在使用该端口并杀死它的进程。
我发现有大量与进程无关的端口被阻塞。这与 AV 或防火墙无关。我关闭了防火墙,我只有 Windows Defender AV。
我写了一个程序来监听 127.0.0.1 上 3000 到 5000 之间的端口。
int port = 3000;
while(port <= 5001)
{
try
{
ListenOnPort(port);
++port;
}
catch (Exception ex)
{
Console.WriteLine($"Listen on {port} failed: {ex.Message}");
++port;
}
}
Run Code Online (Sandbox Code Playgroud)
ListenOnPort 在哪里...
private static void ListenOnPort(int v)
{
var uri = new UriBuilder("http", "127.0.0.1", v);
HttpListener listener = new HttpListener();
listener.Prefixes.Add(uri.Uri.ToString());
Console.WriteLine($"Listening on {v}");
listener.TimeoutManager.IdleConnection …Run Code Online (Sandbox Code Playgroud) docker ×2
android ×1
asp.net-core ×1
c# ×1
dns ×1
http ×1
port ×1
powershell ×1
react-native ×1
windows ×1
windows-10 ×1
xamarin ×1
xaml ×1