gpt4 book ai didi

c# - .NET 4.5 中是否弃用了 Contexts.Context.Parameters?

转载 作者:太空宇宙 更新时间:2023-11-03 10:29:44 24 4
gpt4 key购买 nike

在我大发雷霆之前帮我把房子里所有的毛绒兔子的头都撕下来!!

我只是想遵循 MSDN tutorial用于在 C# 中创建 Windows 服务。在“添加启动参数”子部分下,有以下代码行:

System.Runtime.Remoting.Contexts.Context.Parameters["assemblypath"] = ...

当我在该行中键入符号 Parameters 时,VS2013 (Premium) 显示此错误:“无法解析符号‘Parameters’。”当我在帮助查看器和 MSDN 在线检查 Contexts.Context 类时,Context 确实没有 Parameters 属性。好吧,哎呀,我敢肯定很多人都尝试过这个演练;他们都遇到过这个错误吗?

我用谷歌搜索了几个小时,一切我都找到了有关设置上下文参数、使用上下文参数或两者的讨论。我找不到任何说明 Context.Parameters 已被弃用的内容。

最佳答案

唯一出现的 Context.Parameters 我可以在 that tutorial page 上找到在下面的代码片段中,在“添加启动参数”下的第 3 步中:

protected override void OnBeforeInstall(IDictionary savedState)
{
string parameter = "MySource1\" \"MyLogFile1";
Context.Parameters["assemblypath"] = "\"" + Context.Parameters["assemblypath"] + "\" \"" + parameter + "\"";
base.OnBeforeInstall(savedState);
}

在此方法中,Context 指的是 Context property这是从基础 Installer class 继承而来的,而不是System.Runtime.Remoting.Contexts.Context .

从您的代码中删除 System.Runtime.Remoting.Contexts.,它应该可以成功编译。

关于c# - .NET 4.5 中是否弃用了 Contexts.Context.Parameters?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30657082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com