我正在使用public class MyRepository
{
public List<Defect> GetDefects()
{
MyBridgeContext context = new MyBridgeContext();
return context.Defects.AsNoTracking().ToList(); //AsNoTracking doing nothing
}
public List<User> GetUsers()
{
MyBridgeContext context = new MyBridgeContext();
return context.Users.AsNoTracking().ToList();
}
public List<Order> GetOrders()
{
MyBridgeContext context = new MyBridgeContext();
return context.Orders.AsNoTracking().ToList();
}
}
在另一个服务中安装和卸载Windows服务。问题是安装服务时,服务的System.Configuration.Install.ManagedInstallerClass.InstallHelper
被锁定或其他原因,但是卸载服务后我需要删除服务文件。
服务安装:
exe
服务卸载:
System.Configuration
.Install
.ManagedInstallerClass
.InstallHelper(new string[] { "/i", serviceExePath });
答案 0 :(得分:0)
我遇到了同样的问题。事实证明,#include <cstdlib>
#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int main(){
int N , x, y, z, vt;
cout << "Enter the number of particles: \n";
cin >> N;
cout << "The velocity of the particles are\nx: y: z:\n";
std::srand(time(NULL));
for(int i = 1; i <= N; i++){
int x = std::rand() % vt;
int y = std::rand() % vt;
int z = std::rand() % vt;
vt = 200 - ( std::pow(x,2)+std::pow(y,2)+std::pow(z,2));
cout << "%d" << x << " %d" << y << " %d\n" << z;
}
}
在服务上放置了文件句柄锁定,并且只有在锁定过程终止后才能删除它。
我使用以下代码解决了这个问题:
ManageInstallerClass
var s = new ServiceInstaller
{
Context = new InstallContext(),
ServiceName = "<YOUR SERVICE NAME>"
};
s.Uninstall(null);
完成后,您应该可以删除服务文件。
要使用ServiceInstaller
,您必须在课程中加入ServiceInstaller
。