使用时创建Windows服务:
sc create ServiceName binPath= "the path"
Run Code Online (Sandbox Code Playgroud)
如何将参数传递给Installer类的Context.Parameters集合?
我对sc.exe文档的阅读是这样的论证只能在最后传递binPath,但我没有找到一个例子或者能够成功地做到这一点.
特定
public Class Example
{
public static void Foo< T>(int ID){}
public static void Foo< T,U>(int ID){}
}
Run Code Online (Sandbox Code Playgroud)
问题:
如何在创建MethodInfo对象时指定任一方法?
Type exampleType = Type.GetType("fullyqualifiednameOfExample, namespaceOfExample");
MethodInfo mi = exampleType.GetMethod("Foo", BindingFlags.Public|BindingFlags.Static, null, new Type[] {typeof(Type), typeof(Type) }, null);
Run Code Online (Sandbox Code Playgroud)参数4使编译器非常不满
目标:为了支持在一台计算机上可能有多个实例的Windows服务,请使用安装项目创建一个能够执行以下操作的MSI:
我最初的希望是在App.config中设置服务名称(然后在实例化ServiceInstaller时在卸载期间检索它.这似乎很天真,因为在安装过程中无法访问它.
如果MyInstaller扩展了Installer,它可以调用base.Install(); 但是,我尝试写入app.config(在MyInstaller.Install()内和base.Install()之后)是无效的.
因此,虽然可以使用自定义服务名称安装服务,但该名称未被序列化,安装程序在卸载时最不满意.
该怎么做?
我有一个具有主键和2个外键的类.外国组合必须是唯一的.我没有看到这样做的方法(至少因为不推荐使用SetAttribute).
James用SetAttribute触及了这个: 如何使用NHibernate创建多列索引或唯一约束