关于现在可以用一个命令安装WindowsSubsystemforLinux和的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于BuildSSHforDevelopmentonWindowsS
关于现在可以用一个命令安装Windows Subsystem for Linux和的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Build SSH for Development on Windows Subsystem for Linux、c# – 从WPF窗口获取System.Windows.Forms.IWin32Window、c#无法将’System.Windows.Forms.Label’类型的对象强制转换为’System.Windows.Forms.TextBox’、Docker迎来 Windows Subsystem for Linux 2等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- 现在可以用一个命令安装Windows Subsystem for Linux((用命令行安装win10)
- Build SSH for Development on Windows Subsystem for Linux
- c# – 从WPF窗口获取System.Windows.Forms.IWin32Window
- c#无法将’System.Windows.Forms.Label’类型的对象强制转换为’System.Windows.Forms.TextBox’
- Docker迎来 Windows Subsystem for Linux 2
现在可以用一个命令安装Windows Subsystem for Linux((用命令行安装win10)
在最新的WindowsInsider预览版本中,只需运行wsl.exe--install.
今天微软宣布这项功能现在正式移植到Windows10版本2004及更高版本。•使用WSL--INSTALL
微软表示,之前设置WSL的过程过于复杂,包括打开多个设置和安装多个软件包。该公司已将这一过程简化为一个命令。Windows10用户现在只需打开一个具有管理员权限的命令提示符窗口并运行wsl.exe--install. 一旦点击enter,进程将自动启用所需的WSL可选特性,默认安装Ubuntu发行版,并在您的机器上安装最新的wsllinux内核版本。当它完成并重新启动计算机时,您的发行版将在您再次启动完成安装后启动。
此外,您可以通过输入以下命令找到可供安装的Linux发行版的列表wsl--list--online在PowerShell或Windows命令提示符下。要安装除Ubuntu默认版本之外的发行版,或者除此之外,使用以下命令:wsl公司--安装-d发行版
更换使用在上一个list命令中找到的Linux发行版的名称。这个install命令可以用于第一次安装,或者在已经用默认的Ubuntu发行版安装WSL之后添加其他发行版。
微软还提供了一些额外的命令来帮助您使用这个后台端口管理WSL实例。
你可以用wsl--update要手动更新您的WSL Linux内核,您可以使用wsl公司--更新回滚回滚到以前的WSL Linux内核版本。
最后,您可以使用wsl--status查看有关WSL配置的一般信息,例如默认发行版类型、默认发行版和内核版本。
你只需像平常一样更新Windows就可以得到这个后台端口。若要手动执行此操作,请转到“更新和安全”并单击“检查更新”。
此更新是KB5004296,您可以在这里找到有关如何确保安装了它及其更改的完整说明. 在撰写本文时,当您单击“检查更新”时,您可能会看到一个可用的可选更新,确保它与KB5004296的编号相同,然后安装它,您就可以访问wsl--update.
Build SSH for Development on Windows Subsystem for Linux
It seems that Windows Subsystem for Linux (WSL) is getting much more mature than the time when it first came out. Fewer and fewer people keep questioning its fitness for daily development. Tuning WSL to be a neat developing environment and how to SSH into WSL the topic I am going to share with.
One-Click installation
The installation entry of several Linux distributions available for WSL has been moved to Microsoft Store since the Fall Creators.
It means you can install a Linux distribution as simple as installing an app from the store. The moment I am writing this, Ubuntu, Debian, OpenSUSEand Kali Linux are officially collected into the WSL family.
I choose Debian as my first trial for WSL.
If nothing goes wrong, the familiar icon will show up in the start menu after the installation. Click it, boot it on and create your Linux user account.
As you can see in the Task Manager, required few seconds to get ready, WSL have very small demand for resource and please don''t forget that it is able to offer almost full Linux experience to you. So that is pretty good enough as a subsystem.
By the way, this command can lead you to your C:/.
cd /mnt/c
Similarly, /mnt/d for D:/ and so on.
Simple configuration
You can tweak it in the same way as you play with Linux as usual when you have got this far. The following are things I have done just after the installation.
Update sources.list
Replacing stable to testing will let your Debian have access to the latest version of software updates.
sudo nano /etc/apt/sources.list
Configure locale
Select your language to add UTF8 locales support by doing this.
sudo dpkg-reconfigure locales
Create a shortcut on the desktop
The path to Debian(WSL) root follows the format:
C:\Users\username\AppData\Local\Packages\TheDebianProject.DebianGNULinux_xxxxxxxxxxxxx\LocalState\rootfs
However, do not move or delete or do anything else on files in WSL with Windows File Explorer which might mess up the file permission on Linux File System. That causes tons of problems. Here it can only be used as a single-function graphical File Explorer.
SSH to WSL
Considering that it is a kind of awkward experience to run bash in CMD, so here I introduce MobaXterm to you. Next, we are about to build up an SSH server on WSL and pair it with MobaXterm through SSH connection.
Install OpenSSH server
OpenSSH is the premier connectivity tool for remote login with the SSH protocol.
sudo apt-get install openssh-server
Edit the configuration and change the listening port for the reason that Port 22 as the default setting has been already taken by SSH service running on Windows.
sudo nano /etc/ssh/sshd_config
To make sure SSH server on WSL works well, change Port 22 into Port 2018 or whatever you prefer.
Port 2018
ListenAddress 0.0.0.0
PermitRootLogin prohibit-password
the above is the scanty lines you have to deal with in the sshd_config. Then start the SSH service.
sudo service ssh start
Use MobaXterm to SSH
MobaXterm has not only SSH support but also full X-Server support if you need. Two editions (Home Edition and Professional Edition) are provided with free one and paid one.
I download MobaXterm Home Edition (Portable edition) which already fulfils my demand.
Create a new session and edit its configuration. Remote host is set as127.0.0.1. Remember that Port should be 2018 or the same port you decided several minutes ago. You can tweak other settings catered for your appetite.
If your Debian is running well with SSH enabled, it must work. Select Remember the Password to save the time you type in your password whenever booting the WSL.
Now enjoy WSL with the excellent terminal experience supplied by MobaXterm.
Auto-boot WSL with SSH started
It is so unpleasant to manually start SSH service each time you turn WSL on and the bot to boot WSL at the same time as you log in Windows can be the thing what you want.
Also, you will soon notice that the SSH connection goes bad when you shut down the CMD window which is quite bothering.
Here comes the solution to the three so-called problems.
Auto-start SSH service
Write a shell script named init.sh placed in /home.
sudo -S service ssh start << EOF
<your_password>
EOF
Replace <your_password> to your root password.
The object of the tiny script is to start SSH service in sudo mode when you execute this shell.
Write a VBS script on your Windows host.
Set ws = CreateObject("Wscript.Shell")
ws.run "bash /home/init.sh",vbhide
To mention that, WSL can be start up by typing bash in CMD or Powershell. The script is so self-explain that it will obviously run the init.sh as well after booting WSL.
vbhide at the end of the line tells that it runs silently in the background.
Actually, it doesn''t matter that what sort of name you give to the shell above and where you place it. Just to be sure the path-to-the-shell has to be identical in two scripts.
Auto-boot WSL in background
It is much easier to achieve this goal since the big steps have got settled in the previous move.
Set the VBS script into the scheduled tasks performing when Windows host logins.
Reboot Windows and keep an eye on the Task Manager. if two processes namedinit (depends on the name of the shell) and sshd exist, then you can immediately start MobaXterm to SSH into WSL without any other keyboard job.
Job done
Now, the complete WSL with SSH workflow has been set up.
Thanks for reading :)
原文出处:https://www.cnblogs.com/nczitzk/p/build-ssh-for-development-on-windows-subsystem-for-linux.html
c# – 从WPF窗口获取System.Windows.Forms.IWin32Window
我可以通过使用来获取窗口的IntPtr
new WindowInteropHelper(this).Handle
但这不会转换到System.Windows.Forms.IWin32Window,我需要显示这个WinForms对话框.
如何将IntPtr转换为System.Windows.Forms.IWin32Window?
解决方法
IWin32Window只需要一个Handle属性,这不是很难实现,因为你已经有了IntPtr.实现IWin32Window的Create a wrapper类:
public class WindowWrapper : System.Windows.Forms.IWin32Window { public WindowWrapper(IntPtr handle) { _hwnd = handle; } public WindowWrapper(Window window) { _hwnd = new WindowInteropHelper(window).Handle; } public IntPtr Handle { get { return _hwnd; } } private IntPtr _hwnd; }
你会得到你的IWin32Window这样:
IWin32Window win32Window = new WindowWrapper(new WindowInteropHelper(this).Handle);
或(作为回应KeithS的建议):
IWin32Window win32Window = new WindowWrapper(this);
选项2(thx to Scott ChAmberlain的评论)
使用现有的NativeWindow类,它实现了IWin32Window:
IWin32Window win32Window = new NativeWindow(); win32Window.AssignHandle(new WindowInteropHelper(this).Handle);
c#无法将’System.Windows.Forms.Label’类型的对象强制转换为’System.Windows.Forms.TextBox’
我的代码是;
string[] dersler = new string[9]; double[] kredi = new double[9]; double[] kredisonuclari = new double[9]; double derscarp(double s1,double s2) { return s1 * s2; } private void button1_Click(object sender,EventArgs e) { int i=0; int j = 0; foreach (TextBox item in Controls) { if (item.Name.Substring(0,7)=="txtders") { dersler[i] = Convert.ToString(item.Text); i++; } } foreach (TextBox item in Controls) { if (item.Name.Substring(0,8) == "txtkredi") { kredi[j] = Convert.Todouble(item.Text); j++; } } double toplam =0; for (int k = 0; k < 9; k++) {
解决方法
foreach (TextBox item in Controls)
控件包含一些不是文本框的控件.
您的foreach语句告诉编译器将集合中的每个项目转换为TextBox,这将无法正常工作.
相反,您可以调用.OfType< TextBox>(),它将返回仅包含TextBox实例的集合的已过滤子序列.
Docker迎来 Windows Subsystem for Linux 2
Nicolas 译 分布式实验室
Docker已经意识到,微软方面刚刚推出的Windows Subsystem for Linux 2已经让Windows系统在Docker以及Windows/Linux平台容器开发者群体当中获得了惊人的吸引力。Windows Subsystem for Linux 2(WSL2)[1]已经将Linux内核引入Windows系统。有些朋友可能会问,单单因为WSL确实在模拟Linux方面表现出色,就值得我们给予关注吗?呃……没错。根据Docker公司高级软件开发者Simon Ferquel的观点,单凭这一点就足够了。
在一篇工程博文当中,Ferquel解释称,凭借一己之力将容器技术推向主流的Docker公司正着手将其Docker Desktop开发平台for Windows从全Hyper-V转换为更加轻量化的WSL2 Hyper-V虚拟机。
理由是什么?Ferquel写道,这是因为微软“实际上提供了一套能够真正在轻量级虚拟机当中运行的Linux内核……其比Windows所提供的内核更加轻,与Windows集成效果更紧密,Docker守护程序能够在其中运行良好并获得卓越的性能表现。”
那么效率如何?Ferquel宣称,冷启动条件下WSL2与Docker守护程序的速度“迅如奔雷——在我的开发笔记本上能够在2秒内完成启动;相比之下,目前的Docker Desktop版本启动需要数十秒。”
大家觉得这算快吗?反正Docker认为这是相当的快。
然而,转移至WSL2的决定仍然经历了一定探讨。Docker方面测试了早期WSL2的多个build,并对多种方案进行了原型设计。现在,更新更快的Docker Desktop正在开发人员的手中逐步成型。
Docker还将利用WSL2集成包取代原本的Hyper-V VM。其将具有与当前Docker Desktop相同的功能,具体包括Kubernetes一键设置、自动更新、透明HTTP代理配置、访问Windows中的守护程序以及透明绑定Windows文件挂载等等。
真正令Docker开发者们感到振奋的是,他们将能够同时开发Windows与Linux版本的容器化程序。Ferquel宣称这将给面向Linux环境的项目或者Linux定制型build流程的开发者群体带来巨大的推动作用。这意味着大家不再需要分别构建Linux与Windows版程序的维护脚本!举例来说,Docker开发人员现在可以与Linux平台上的开发者使用相同的一组工具及脚本,并直接在Windows之上运行Linux Docker守护程序。
他同时宣称,WSL的绑定挂载还将具有与本机Linux设备几乎完全相同的I/O性能。这将直接解决Docker Desktop面临的主要痛点之一——I/O密集型工具链。NodeJS、PHP以及其它Web开发工具都将从这一改进中受益。
当然,困扰旧版Docker Desktop的绝不只有性能问题。可以肯定地讲,Windows文件绑定挂载的可靠性已经无法满足要求。“目前的实施方案依赖于Samba Windows服务,但该服务可能被停用、可能被企业GPO阻止、被第三方防火墙阻止等等。Docker Desktop配合WSL 2将带来一种新的Windows文件绑定实现方式,从而提供开箱即用且「丝般顺滑」的使用体验。”
除此之外,“与Visual Studio Code的「Remote to WSL」相结合,Docker Desktop Linux工作区将能够运行完整的Linux工具链,从而通过Windows系统中的IDE在本地计算机上构建容器。”
那么,速度提升到底源自何处?
首先,WSL 2运行在面向Windows的原生Linux 4.19内核之上。初代WSL需要先将Linux系统调用转换为相应的Windows API;相比之下,WSL 2则能够在轻量级Hyper-V VM当中运行Linux,因此不会因系统调用转换而带来任何性能损失。
另一大重要性能提升来源则在于Linux文件系统,也就是目前广泛使用的Linux EXT4文件系统。此前,系统必须将文件I/O调用转换为Windows NTFS格式。为了实现文件系统桥接,微软公司决定使用一套性能出众的传统解决方案:Plan 9文件系统协议(简称9P)[2]。9P网络文件系统服务器[3]允许各操作系统顺畅对接彼此之间的不同文件系统。
此次转换带来的最终结果,就是让用户能够在Linux与Windows上获得各自原生文件系统的I/O性能。
当然,如今讨论这一切可能为时尚早。毕竟Docker Desktop for WSL 2技术预览版还没有实际发布,预计将在今年7月开放下载。Docker方面承诺其将能够与现有Docker Desktop版本并行运作,因此大家可以继续安全地推进现有项目的开发工作。
如果新的Docker Desktop真的能够践行这些承诺,那么相信它必将成为涵盖Windows Server、Linux服务器、乃至全部云环境的至高Windows Docker开发平台。
相关链接:
https://www.zdnet.com/article/hell-freezing-over-microsoft-releases-its-own-linux-for-windows/
https://wiki.tcl-lang.org/page/9P+%28Plan+9+Filesystem+Protocol%29+VFS
https://nelsonslog.wordpress.com/2019/02/16/plan-9-rides-again-wsl-file-access/
今天关于现在可以用一个命令安装Windows Subsystem for Linux和的介绍到此结束,谢谢您的阅读,有关Build SSH for Development on Windows Subsystem for Linux、c# – 从WPF窗口获取System.Windows.Forms.IWin32Window、c#无法将’System.Windows.Forms.Label’类型的对象强制转换为’System.Windows.Forms.TextBox’、Docker迎来 Windows Subsystem for Linux 2等更多相关知识的信息可以在本站进行查询。
本文标签: