小编Jes*_*aya的帖子

ASP.Net Core 1.0 RC2:web.config中提到的LAUNCHER_PATH和LAUNCHER_ARGS是什么?

ASP.NET 5 RC2版本中有重大变化:

  • 它被重新命名为ASP.NET Core 1.0(ASP.NET 5已经死了)
  • 再见dnvmdnu命令行,它们被替换为dotnet
  • 各种必要的代码更改

我正在尝试部署生成的文件dotnet publish.文件结构与RC1不同.我在事件查看器中看到以下错误:

Failed to start process with commandline '%LAUNCHER_PATH% %LAUNCHER_ARGS%', Error Code = '0x80070002'.

提到了这些环境变量web.config,它取自官方的rc1到rc2文档.

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*"
              modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"
        stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
        forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

什么是正确的价值观%LAUNCHER_PATH%%LAUNCHER_ARGS%?这些值在其github发布文档中未提及.

asp.net asp.net-core

40
推荐指数
3
解决办法
2万
查看次数

如何手动调用事件?

我在C#中有以下行:

_timer.ElapsedTick += _somefunction1;
_timer.ElapsedTick += _somefunction2;
_timer.ElapsedTick += _somefunction3;
Run Code Online (Sandbox Code Playgroud)

如何在不指定_somefunction的情况下调用订阅_timer.ElapsedTick的所有方法?沿着这条伪线的某个地方

invoke(_timer.ElapsedTick);
Run Code Online (Sandbox Code Playgroud)

非常感激您的帮忙.

更新

@ M.Babcock的例子正在发挥作用.FireEvent方法具有魔力.谢谢.

class InvokeFromMe
{
    public event EventHandler RaiseMe;
}
class MainClass
{
    public MainClass()
    {
        InvokeFromMe fromMe = new InvokeFromMe();
        fromMe.RaiseMe += fromMe_RaiseMe;
        fromMe.RaiseMe += fromMe_RaiseMe1;
        FireEvent(fromMe, "RaiseMe", null, EventArgs.Empty);
        //works

        System.Timers.Timer _timer = new System.Timers.Timer();
        _timer.Elapsed += _timer_Elapsed;
        FireEvent(_timer, "onIntervalElapsed", null, null);
        //throws exception
    }
    private void _timer_Elapsed(object sender, ElapsedEventArgs e)
    {
        Console.WriteLine("_timer_Elapsed raised");
    }
    private void fromMe_RaiseMe(object sender, EventArgs e)
    {
        Console.WriteLine("Event Handler …
Run Code Online (Sandbox Code Playgroud)

c# events

22
推荐指数
3
解决办法
6万
查看次数

为什么我的析构函数永远不会运行?

我有一个带有析构函数方法的空白Winform

public partial class Form1 : Form
{
    public Form1()
    {
        System.Diagnostics.Trace.WriteLine("Form1.Initialize " + this.GetHashCode().ToString());
        InitializeComponent();
    }
    ~Form1()
    {
        System.Diagnostics.Trace.WriteLine("Form1.Dispose " + this.GetHashCode().ToString());
    }
}
Run Code Online (Sandbox Code Playgroud)

当表单被销毁时,我希望它写入输出窗口:

(Form1 opened)
Form1.Initialize 41149443
(Form1 closed)
Form1.Dispose 41149443

MSDN建议实现析构函数的3种方法:

但是,这些方法都不会将"Form1.Dispose 41149443"写入输出窗口.因此,我无法判断表格是否已被销毁.建议?

由于垃圾收集器的不确定性,我是否应该放弃实现这一目标的希望?

还有另一种方法可以知道Form1是否被垃圾收集?

c# garbage-collection winforms

14
推荐指数
1
解决办法
2万
查看次数

Windows应用商店应用在哪里存储其本地设置?

程序员大家好,

我是Windows 8的新手.Windows Store应用程序的LocalSettings在哪里存储其序列化文件?我指的是这个:

Windows.Storage.ApplicationData.Current.LocalSettings
Run Code Online (Sandbox Code Playgroud)

每WinStore应用教程在这里,我可以加载和保存序列化的属性要么漫游设置或本地设置.漫游进入云端,但本地设置究竟在哪里?注册?孤立的文件?

先感谢您.

microsoft-metro windows-8 windows-store-apps

13
推荐指数
1
解决办法
2万
查看次数

CAB与棱镜的比较

我有需要重写的Winform.我知道我们在WPF中有Prism.对于那些经历过两者的人来说,这两个框架之间的重要区别是什么?我是CAB程序员,所以我已经习惯了CAB事件接线.

此外,Prism是否适用于Winforms?CAB是否适用于WPF?

c# wpf prism cab winforms

5
推荐指数
1
解决办法
2637
查看次数

使用命名空间和多个嵌套元素反序列化XML

我试图反序列化以下的xml

<?xml version="1.0" encoding="utf-8"?>
<ns2:myroot xmlns:ns2="http://jeson.com/">
  <item>
    <name>uno</name>
    <price>1.25</price>
  </item>
  <item>
    <name>dos</name>
    <price>2.30</price>
  </item>
</ns2:myroot>
Run Code Online (Sandbox Code Playgroud)

与这些课程

public class item
{
    [XmlElement(Namespace="")]
    public string name { get; set; }

    [XmlElement(Namespace = "")]
    public double price { get; set; }
}

[XmlRoot("myroot", Namespace="http://jeson.com/")]  //This was http://jeson.com, no slash at the end.
public class myrootNS
{
    [XmlElement(Namespace = "")]
    public item[] item { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

使用这种方法

XmlSerializer serializer = new XmlSerializer(typeof(T), "http://jeson.com/");
XmlReaderSettings settings = new XmlReaderSettings();
using (StringReader textReader = …
Run Code Online (Sandbox Code Playgroud)

c# xml

5
推荐指数
1
解决办法
1万
查看次数

Perforce解决方法以“ @”添加文件

根据设计,Perforce不允许@#%*添加带通配符的文件名。它给出了这个错误:

Can't add filenames with wildcards [@#%*] in them.
Use -f option to force add.
Run Code Online (Sandbox Code Playgroud)

但是,我有@支持混入的SASS文件。例如:

carbon-fibre-@2X.png
sprite-dashboard-@2X.png
Run Code Online (Sandbox Code Playgroud)

将这些文件添加到Perforce 的最佳解决方法是什么,而对签入,签出,编译,构建和部署流程的干扰最小?

perforce

5
推荐指数
1
解决办法
2891
查看次数

使用System.Threading.Task访问winform控件会卡住

新的Task类在WPF中运行良好.但是在Winforms中,每次尝试访问Winform控件时它总是卡住.下面的"InvokeRequired"例程一直在使用BackgroundWorker和Thread类来防止跨线程操作错误.但是,由于某些原因,当涉及到Task时,它会停留在Invoke方法上.救命 ?

这是一个示例代码.我使用.NET 4.5.1框架.

using System;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinformTaskDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string now = DateTime.Now.ToString();
            Task t = new Task(() => { setText(now); });
            t.Start();
            t.Wait();
        }

        private void setText(string text)
        {
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(new Action(() => textBox1.Text = text)); //stuck forever here
            }
            else
            {
                textBox1.Text = text;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# multithreading winforms task-parallel-library

4
推荐指数
1
解决办法
1475
查看次数

HtmlAgilityPack - 后代的 SelectSingleNode

我发现 HtmlAgilityPackSelectSingleNode总是从原始 DOM 的第一个节点开始。是否有等效的方法来设置其起始节点?

示例 HTML

<html>
  <body>
    <a href="https://home.com">Home</a>
    <div id="contentDiv">
    <tr class="blueRow">
        <td scope="row"><a href="https://iwantthis.com">target</a></td>
    </tr>
    </div>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

不起作用的代码

//Expected:iwantthis.com  Actual:home.com, 
string url = contentDiv.SelectSingleNode("//tr[@class='blueRow']")
                       .SelectSingleNode("//a") //What should this be ?
                       .GetAttributeValue("href", "");
Run Code Online (Sandbox Code Playgroud)

我必须用以下代码替换上面的代码:

    var tds = contentDiv.SelectSingleNode("//tr[@class='blueRow']").Descendants("td");
    string url = "";
    foreach (HtmlNode td in tds)
    {
        if (td.Descendants("a").Any())
        {
            url= td.ChildNodes.First().GetAttributeValue("href", "");
        }
    }
Run Code Online (Sandbox Code Playgroud)

我在 .Net Framework 4.6.2 上使用 HtmlAgilityPack 1.7.4

html-agility-pack

1
推荐指数
1
解决办法
958
查看次数