Re: ATL Service EXE VS .NET 2003 - Won't register method
Sorry that I did not give your guys clear decription. The error I got is
"ACCESSDENIED" at this code line
HRESULT hRes = m_DvrCtrl.CreateInstance("DVRService.DVRController");
1. I created ATL service EXE NOT server EXE
2. I created 2 method to control the service threads (OnStart) and (OnStop)
which will call from client application
3. I created the test client
4. I register the marshall dll as regsrv32 servicenamePS.dll
5. I register the service as servicename.exe /service
6. I tried to call the interfaces as following
#include "stdafx.h"
#include "TestDvrCtrl.h"
#import "C:\temp\Atl-Tutorials\DVRService\_DVRService.tlb"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
DVRService::IDVRControllerPtr m_DvrCtrl;
HRESULT hr = CoInitialize( NULL );
HRESULT hRes = m_DvrCtrl.CreateInstance("DVRService.DVRController");
if ( FAILED(hRes) )
{
_com_error err(hRes);
AfxMessageBox(err.ErrorMessage());
}
char szMessage[MAX_PATH];
ZeroMemory( szMessage, MAX_PATH );
DOUBLE dbReturnCode = 0;
strcpy( szMessage, "this is me" );
int iLen = strlen(szMessage);
m_DvrCtrl->OnStart(szMessage, (DOUBLE) iLen, &dbReturnCode );
m_DvrCtrl->OnStop();
m_DvrCtrl.Release();
CoUninitialize();
// TODO: code your application's behavior here.
}
return nRetCode;
}
"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:OwAef6OiHHA.492@TK2MSFTNGP04.phx.gbl...
My guess based on your very garbled description is you haven't
registered marshaling support for your interfaces. With ATL7 and
above (VC7 and above) the ATL appwizard creates a project
in your workspace to build and register the proxy/stub DLL for
the interfaces defined in your IDL file in your main ATL project.
Build that project. For VC6 the mechanics are slightly different -
post back if you are using VC6.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Danh Vo" <DanhVo@discussions.microsoft.com> wrote in message
news:46E9C05E-28E7-47AC-A66E-52F21310F2A1@microsoft.com...
Hi everyone!
I created an ATL service EXE with 2 interface methods. After compiled
with
no error, the service was running fine and show under service manager but
the
methods did not register under windows registry and I can't build a
client
to
talk with these 2 interfaces method. Does anyone have this problems or
doing
similar thing like this before? I need some assistant or point me to
some
place have the tutorial of how to create ATL service EXE and create
method
interfaces.
Thank you in advance for your time and your help.