windows服务安装出错的问题!!

myall2002 2003-08-26 10:54:25
用vc.net向导生成一个windows服务server.exe!
用命令 installutil server.exe 安装出错!
出错信息:
在初始化安装时发生异常:
System.IO.FileLoadException:不能运行无法验证的图像“evtrfsrv.exe”。。
...全文
484 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
panyee 2003-08-26
  • 打赏
  • 举报
回复
不好意思,没做过vc.net的
myall2002 2003-08-26
  • 打赏
  • 举报
回复
它的模板中只提供安装的方法,没有卸载的方法,应该怎样写才对呢?
myall2002 2003-08-26
  • 打赏
  • 举报
回复
to panyee(快乐王子) :
那请问你应该用什么来安装呢?应该怎样才能使用vc.net来做的服务呢?多谢!!
panyee 2003-08-26
  • 打赏
  • 举报
回复
vc.net的服务不是用installutil来安装

vc#.net做的服务可以
csharplove 2003-08-26
  • 打赏
  • 举报
回复
关注
myall2002 2003-08-26
  • 打赏
  • 举报
回复
if (argc >= 2)
{
if (argv[1][0] == _T('/'))
{
argv[1][0] = _T('-');
}
//使用 InstallUtil.exe 安装此 Windows 服务
String* myargs[] = System::Environment::GetCommandLineArgs();
String* args[] ;

AppDomain* dom = AppDomain::CreateDomain(S"execDom");
Type* type = __typeof(System::Object);
String* path = type->get_Assembly()->get_Location();
StringBuilder* sb = new StringBuilder(path->Substring(0, path->LastIndexOf(S"\\")));
if (_tcsicmp(argv[1], _T("-Install")) == 0)
{
args = new String*[myargs->Length-1 ];
sb->Append(S"\\InstallUtil.exe");
args[0] = (myargs[0]);
Array::Copy(myargs, 2, args, 1, args->Length -1);
}
else
{
args = new String*[myargs->Length];
sb->Append(S"\\InstallUtil.exe");
args[0] = S"/u";
args[1] = (myargs[0]);
// Array::Copy(myargs, 2, args, 2, args->Length -2);
}
for( int i = 0 ;i < args->Length ; i++)
Console::WriteLine(args[i]);
dom->ExecuteAssembly(sb->ToString(), 0, args);
}
else
{
ServiceBase::Run(new evTrfSrvWinService());
}
return 0;

OK!!!!!!!
myall2002 2003-08-26
  • 打赏
  • 举报
回复
//若要安装服务,请键入: "server.exe -Install"
int _tmain(int argc, _TCHAR* argv[])
{
if (argc >= 2)
{
if (argv[1][0] == _T('/'))
{
argv[1][0] = _T('-');
}
//使用 InstallUtil.exe 安装此 Windows 服务
String* myargs[] = System::Environment::GetCommandLineArgs();
String* args[] ;

AppDomain* dom = AppDomain::CreateDomain(S"execDom");
Type* type = __typeof(System::Object);
String* path = type->get_Assembly()->get_Location();
StringBuilder* sb = new StringBuilder(path->Substring(0, path->LastIndexOf(S"\\")));
if (_tcsicmp(argv[1], _T("-Install")) == 0)
{
args = new String*[myargs->Length -1];
sb->Append(S"\\InstallUtil.exe");
args[0] = (myargs[0]);
Array::Copy(myargs, 2, args, 1, args->Length -1);
}
if (_tcsicmp(argv[1], _T("-unInstall")) == 0)
{
args = new String*[myargs->Length];
args[0] = S"/u";
args[1] = (myargs[0]);
Array::Copy(myargs, 2, args, 2, args->Length -2);
}
for( int i = 0 ;i < args->Length ; i++)
Console::WriteLine(args[i]);
dom->ExecuteAssembly(sb->ToString(), 0, args);

}
else
{
ServiceBase::Run(new serverWinService());
}
return 0;
}
当使用server.exe -install安装时成功!
但使用server.exe -uninstall卸载时失败!
错误信息:未处理的异常: System.IO.FileLoadException: 访问被拒绝:“v1.1.4322”。
文件名: “v1.1.4322”
请问应该怎样处理??
myall2002 2003-08-26
  • 打赏
  • 举报
回复
哦!!没关系!!
有谁做过的吗??

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧