I am trying to build a new windows Service that i can run as a console App during debug. My thought is that i would need instantiate the service class and spit all output to the console.
So instead of using the below call it would be the new instance.
ServiceBase::Run(gcnew myWinService());
Currently it is a skeleton and just want to get some insight on this. Thanks!
int _tmain(int argc, _TCHAR* argv[]) {
if (argc >= 2) {
if (argv[1][0] == _T('/'))
argv[1][0] = _T('-');
if (_tcsicmp(argv[1], _T("-Install")) == 0) {
array<String^>^ myargs = System::Environment::GetCommandLineArgs();
array<String^>^ args = gcnew array<String^>(myargs->Length - 1);
// Set args[0] with the full path to the assembly,
Assembly^ assem = Assembly::GetExecutingAssembly();
args[0] = assem->Location;
Array::Copy(myargs, 2, args, 1, args->Length - 1);
AppDomain^ dom = AppDomain::CreateDomain(L"execDom");
Type^ type = System::Object::typeid;
String^ path = type->Assembly->Location;
StringBuilder^ sb = gcnew StringBuilder(
path->Substring(0, path->LastIndexOf(L"\\")));
sb->Append(L"\\InstallUtil.exe");
Evidence^ evidence = gcnew Evidence();
dom->ExecuteAssembly(sb->ToString(), evidence, args);
}
} else
ServiceBase::Run(gcnew myWinService());
}