Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF应用程序没有';不要在平板电脑上运行_C#_Wpf_Notifyicon - Fatal编程技术网

C# WPF应用程序没有';不要在平板电脑上运行

C# WPF应用程序没有';不要在平板电脑上运行,c#,wpf,notifyicon,C#,Wpf,Notifyicon,我编写了一个简单的wpf应用程序,它处理TCPIP和串行通信。在第一个版本的应用程序中,我使用了带有连接按钮的“GUI”等等。这个版本在平板电脑上运行。平板电脑是一款带有Windows 8的ThinkPad 应用程序的第二个版本应该在没有任何GUI的情况下运行,但带有任务栏图标。我能够创建任务栏图标等等。这个应用程序在我的电脑上运行得很好。可以在平板电脑上安装该应用程序,但它无法运行 有人知道为什么应用程序无法打开吗 在下面你可以找到一些源代码,我是如何创建图标的等等。在VisualStudio

我编写了一个简单的wpf应用程序,它处理TCPIP和串行通信。在第一个版本的应用程序中,我使用了带有连接按钮的“GUI”等等。这个版本在平板电脑上运行。平板电脑是一款带有Windows 8的ThinkPad

应用程序的第二个版本应该在没有任何GUI的情况下运行,但带有任务栏图标。我能够创建任务栏图标等等。这个应用程序在我的电脑上运行得很好。可以在平板电脑上安装该应用程序,但它无法运行

有人知道为什么应用程序无法打开吗

在下面你可以找到一些源代码,我是如何创建图标的等等。在VisualStudio项目中,我禁用了“主窗口”,如下所示

xml代码

Title="MainWindow" Height="350" Width="525" Visibility="Hidden">
c#-代码

编辑

是否可能需要System.Windows.Input using指令才能在平板电脑上启动应用程序?由于与另一个using指令发生冲突,我不得不排除该指令


还有一个问题。我相信这是Windows8的错误。该应用程序正在我的Win7机器上运行,但既不在Win8笔记本电脑上也不在Win8平板电脑上运行。

您尝试运行它时遇到了什么平板电脑以及什么错误?“它就是不运行”,这意味着什么?有错误信息吗?如果它启动并以静默方式终止,您可以在主窗口构造函数中的所有代码周围添加一个try块,并显示一个包含异常消息的消息框。或者在事件日志中搜索最近的.NET错误消息。您得到的错误是什么?而且,这里的一切都是winforms。你想做什么?嘿嘿,当我尝试在平板电脑上打开应用程序时,我没有收到任何错误。这款平板电脑是一款配备Windwos 8的联想Thinkpad。当我点击应用程序的图标时,平板电脑会切换到桌面,什么也不做。。克莱门斯,我该怎么做?或者您在事件日志中搜索一些最近的.NET错误消息我不认为windows mobile 8(WinRT)框架与WPF兼容,您必须检查WinRT框架,该框架与XAML兼容,但与WPF不兼容,因此了解平板电脑是否在满负荷运行windows 8或WinRT很重要
public MainWindow()
  {
     InitializeComponent();

     // Initailize Menu
     this.components = new System.ComponentModel.Container();
     this.contextMenu1 = new System.Windows.Forms.ContextMenu();
     this.menuItem1 = new System.Windows.Forms.MenuItem();
     this.menuItem2 = new System.Windows.Forms.MenuItem();
     this.menuItem3 = new System.Windows.Forms.MenuItem();
     this.menuItem4 = new System.Windows.Forms.MenuItem();

     // Initialize contextMenu1
     this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1 });
     this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem2 });
     this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem3 });
     this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem4 });

     // Initialize Menu Items
     this.menuItem3.Index = 0;
     this.menuItem3.Text = "Connect";
     this.menuItem3.Click += new System.EventHandler(this.Connect);
     //
     this.menuItem2.Index = 1;
     this.menuItem2.Text = "Disconnect";
     this.menuItem2.Click += new System.EventHandler(this.Disconnect);
     //
     this.menuItem4.Index = 2;
     this.menuItem4.Text = "About";
     this.menuItem4.Click += new System.EventHandler(this.About);
     //
     this.menuItem1.Index = 3;
     this.menuItem1.Text = "Exit";
     this.menuItem1.Click += new System.EventHandler(this.Exit);

     // Create the NotifyIcon.
     this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

     // The Icon property sets the icon that will appear
     // in the systray for this application.
     notifyIcon1.Icon = new Icon("icon.ico");

     // The ContextMenu property sets the menu that will
     // appear when the systray icon is right clicked.
     notifyIcon1.ContextMenu = this.contextMenu1;

     // The Text property sets the text that will be displayed,
     // in a tooltip, when the mouse hovers over the systray icon.
     notifyIcon1.Text = "Icon Test";
     notifyIcon1.Visible = true;

     //Handle the Click event
     notifyIcon1.MouseUp += new MouseEventHandler(ShowContextMenu);
  }