小编yme*_*rej的帖子

如何以编程方式关闭或打开"Windows功能"

目前,用户必须进入控制面板>程序>打开或关闭Windows功能,然后单击要激活的功能的复选框.我想让他们能够从我的应用程序中执行此操作.

有关如何通过.NET自动化此过程的任何想法(最好是在C#中)?

.net c# windows controlpanel

8
推荐指数
2
解决办法
6802
查看次数

如何使用"本地系统"服务作为域用户运行单独的进程?

我有以下简单的服务程序:

using System.Diagnostics;
using System.ServiceProcess;

namespace BasicService
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            ProcessStartInfo processStartInfo = new ProcessStartInfo
                                                    {
                                                        Verb = "runas",
                                                        UserName = "jdoe",
                                                        Password = "XXXXXXX".ConvertToSecureString(),
                                                        Domain = "abc.com",
                                                        UseShellExecute =false,
                                                        FileName = "notepad.exe"
                                                    };
            Process.Start(processStartInfo);
        }

        protected override void OnStop()
        {
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用它作为我的服务安装程序:

using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;

namespace BasicService
{
    [RunInstaller(true)]
    public class ProjectInstaller : Installer
    {
        private readonly ServiceProcessInstaller …
Run Code Online (Sandbox Code Playgroud)

c# impersonation windows-services process localsystem

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

HelloWorld示例,用于通过EasyNetQ在两个不同的应用程序之间通过RabbitMQ发送对象

嗨,我试图通过EasyNetQ通过RabbitMQ发送一个简单的对象.我在订阅方面反序列化该对象时遇到问题.任何人都能告诉我一个如何工作的样本.请记住,正在发送的对象是在其自己的项目中定义的,而不是在发布者和订阅者之间共享.这是我的样本,也许你可以告诉我它有什么问题?

计划A:

class ProgramA
{
    static void Main(string[] args)
    {
        using (var bus = RabbitHutch.CreateBus("host=localhost"))
        {
            Console.WriteLine("Press any key to send the message");
            Console.ReadKey();
            bus.Publish(new MessageA { Text = "Hello World" });
            Console.WriteLine("Press any key to quit");
            Console.ReadKey();
        }
    }

    public class MessageA
    {
        public string Text { get; set; }
    }
}
Run Code Online (Sandbox Code Playgroud)

方案B:

class ProgramB
{
    static void Main(string[] args)
    {
        using (var bus = RabbitHutch.CreateBus("host=localhost"))
        {
            bus.Subscribe<MessageB>("", HandleClusterNodes);
            Console.WriteLine("Press any key to quit");
            Console.ReadKey();
        }
    }

    private static …
Run Code Online (Sandbox Code Playgroud)

c# rabbitmq easynetq

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

如何在 NancyFX SelfHost 中将所有请求从 HTTP 转发/重定向到 HTTPS?

我试图得到它,以便任何请求:

http://<myserver>:1234

被重定向到:

https://<myserver>:1234

我试过在模块中使用“this.RequiresHttps()”,但是当我点击 url 时http://<myserver>:1234,浏览器只是旋转,我猜这是因为我没有NancyHost用 HTTP URI构造。我无法将 HTTP URI 与 HTTPS URI 一起添加到 NancyHost,如下所示:

var host = new NancyHost(new Uri("http://localhost:1234"), new Uri("https://localhost:1234"));

因为我会遇到注册冲突。

有任何想法吗?

https redirect http self-hosting nancy

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