Access Denied in VC++ COM
-
Ho extremely sorry...Now no errors..But y is the access denied...sorry to bug u alot..Thank u..
Is there something to do with the firewall settings...I'm not sure if firewall settings has to something with COM..Thank u in advance..
-
Is there something to do with the firewall settings...I'm not sure if firewall settings has to something with COM..Thank u in advance..
RevathiRamakumar wrote:
Is there something to do with the firewall settings...I'm not sure if firewall settings has to something with COM.
If you would be using DCOM, Distributed COM, where the server and client resides on different machines, a network firewall may present some troubles. Some firewalls, such as Comodo, could prevent the client process from accessing the server process or ask the user for action. However, I very much doubt any firewall would cause any troubles in your case since you're able to successfully call other functions of the same interface of the same server.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
Ho extremely sorry...Now no errors..But y is the access denied...sorry to bug u alot..Thank u..
RevathiRamakumar wrote:
Ho extremely sorry...
No worries, you were not the only one who made a mistake.
RevathiRamakumar wrote:
Now no errors..
Good.
RevathiRamakumar wrote:
But y is the access denied
What are you trying to do when do you experience this? Have you tried to debug it and step though the code? Does the
BSTR
variable point to a valid string? What does the source code look like where you get this error?"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
RevathiRamakumar wrote:
Ho extremely sorry...
No worries, you were not the only one who made a mistake.
RevathiRamakumar wrote:
Now no errors..
Good.
RevathiRamakumar wrote:
But y is the access denied
What are you trying to do when do you experience this? Have you tried to debug it and step though the code? Does the
BSTR
variable point to a valid string? What does the source code look like where you get this error?"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknownThanks for ur reply..Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception... HRESULT hr1; hr1 = pGetStatus->raw_Get_Beat(&pbstrTheBeat);//This raises Access Denied /*BSTR does not point to a valid String..It shows 0xc000000 */ if( SUCCEEDED( hr1 ) ) { AfxMessageBox("Text"); } else { _com_error e(hr1); AfxMessageBox(e.ErrorMessage()); } } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP);//This tells me ACCESS IS DENIED } I tried to debug..Actually the purpose is that I need to get the CPU and Memory usuage of a Server machine which is remote..I wanted to try it on a local machine first and then to implement on a remote machine..But, in the local machine itself I get Access Denied..Can u please tell me how to solve this...Thank u in advance...
-
Thanks for ur reply..Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception... HRESULT hr1; hr1 = pGetStatus->raw_Get_Beat(&pbstrTheBeat);//This raises Access Denied /*BSTR does not point to a valid String..It shows 0xc000000 */ if( SUCCEEDED( hr1 ) ) { AfxMessageBox("Text"); } else { _com_error e(hr1); AfxMessageBox(e.ErrorMessage()); } } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP);//This tells me ACCESS IS DENIED } I tried to debug..Actually the purpose is that I need to get the CPU and Memory usuage of a Server machine which is remote..I wanted to try it on a local machine first and then to implement on a remote machine..But, in the local machine itself I get Access Denied..Can u please tell me how to solve this...Thank u in advance...
RevathiRamakumar wrote:
Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception...
:confused: I assumed you were able to call the two other functions successfully since you wrote
RevathiRamakumar wrote:
when I try to call the third method(returns the BSTR srting) I get Access Denied error.
in your original post. I suggest you unregister the server, rebuild the complete server and register it. Clean up the client project, and especially the files generated when #importing the typelib of the server. Rebuild the client, debug it and verify that the server can be successfully created, i.e. make sure that the HRESULT returned from
::CoCreateInstance()
equals zero and your interface pointer points to a valid address. Also make sure you have thenamed_guids
attribute when #importing since this will declare the CLSID and IIDs correctly for you."It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
RevathiRamakumar wrote:
Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception...
:confused: I assumed you were able to call the two other functions successfully since you wrote
RevathiRamakumar wrote:
when I try to call the third method(returns the BSTR srting) I get Access Denied error.
in your original post. I suggest you unregister the server, rebuild the complete server and register it. Clean up the client project, and especially the files generated when #importing the typelib of the server. Rebuild the client, debug it and verify that the server can be successfully created, i.e. make sure that the HRESULT returned from
::CoCreateInstance()
equals zero and your interface pointer points to a valid address. Also make sure you have thenamed_guids
attribute when #importing since this will declare the CLSID and IIDs correctly for you."It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknownThanks for the reply Roger..I tried the way u suggested.. I unregistered the server ,built it again and then registered it..I also cleaned up the client and tried to built it again..HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method... :(
-
Hi all...I have a server Component which is a inprocess exe and a dialog based client... Server has 3 methods ..One method returning CPU usuage , other method returning the memory usuage and the third method just returns a BSTR String... In client code ,when I try to call the third method(returns the BSTR srting) I get Access Denied error.. How can I overcome this issue...:confused: Thank u.. Here's my sample code..(Client). CoInitialize(NULL); HRESULT hr = NULL,hr1=NULL; IGetStatus* pGetStatus; hr=CoCreateInstance(CLSID_GetStatus,NULL,CLSCTX_LOCAL_SERVER,IID_IGetStatus,(void **)&pGetStatus); if(SUCCEEDED(hr)) { try { _bstr_t str1 ; str1 = pGetStatus->GetBeat(); char* Text = _com_util::ConvertBSTRToString(str1); AfxMessageBox(Text); ::SysFreeString(str1); UINT CPU_Info = pGetStatus->Get_CPU(); int Memory_Info = pGetStatus->Get_Memory(); } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP); } }
-
Thanks for the reply Roger..I tried the way u suggested.. I unregistered the server ,built it again and then registered it..I also cleaned up the client and tried to built it again..HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method... :(
RevathiRamakumar wrote:
HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method...
That's odd... If you're able to successfully create the server and get a valid pointer to the interface, I cannot see how you could get an access violation making the call. It feels like there's some kind of mismatch between the server, typelib and client. If you have changed from an IDispatch-derived interface to an IUnknown-derived, the virtual table the client tries to use may be out of sync. That's why I suggested that you should unregister all and rebuild from scratch. How is your interface declared in the IDL-file? It should be something like this:
[
object,
uuid( xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ),
oleautomation,
helpstring( "IGetStatus interface" ),
]
interface IGetStatus : IUnknown
{
HRESULT GetBeat( [out] BSTR* pbstrTheBeat );
HRESULT GetCPU( [out] unsigned long* pulCpuLoad );
HRESULT GetMemory( [out] unsigned long* pulMemory );
};Also make sure in the client that the
IGetStatus
interface, declared in the complier generated header file, only containsQueryInterface()
,AddRef()
,Release()
,GetBeat()
,GetCPU()
andGetMemory()
. Try using one of the other interface functions since it's more straight forward with integer values and you don't have to worry about string obscurities. When you get that working you can continue withIGetStatus::GetBeat()
."It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
RevathiRamakumar wrote:
HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method...
That's odd... If you're able to successfully create the server and get a valid pointer to the interface, I cannot see how you could get an access violation making the call. It feels like there's some kind of mismatch between the server, typelib and client. If you have changed from an IDispatch-derived interface to an IUnknown-derived, the virtual table the client tries to use may be out of sync. That's why I suggested that you should unregister all and rebuild from scratch. How is your interface declared in the IDL-file? It should be something like this:
[
object,
uuid( xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ),
oleautomation,
helpstring( "IGetStatus interface" ),
]
interface IGetStatus : IUnknown
{
HRESULT GetBeat( [out] BSTR* pbstrTheBeat );
HRESULT GetCPU( [out] unsigned long* pulCpuLoad );
HRESULT GetMemory( [out] unsigned long* pulMemory );
};Also make sure in the client that the
IGetStatus
interface, declared in the complier generated header file, only containsQueryInterface()
,AddRef()
,Release()
,GetBeat()
,GetCPU()
andGetMemory()
. Try using one of the other interface functions since it's more straight forward with integer values and you don't have to worry about string obscurities. When you get that working you can continue withIGetStatus::GetBeat()
."It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknownThanks for ur reply...When I tried calling AddRef() It worked fine... ULONG i = pGetStatus->AddRef();//i=2 But, when the other methods are being called, it gives me access denied error..K I'll keep trying ..Thank u...
-
try
{
_bstr_t str1 ;
str1 = pGetStatus->GetBeat();char* Text = str1;
AfxMessageBox(Text);UINT CPU_Info = pGetStatus->Get_CPU();
int Memory_Info = pGetStatus->Get_Memory();
}With best wishes, Vita
Thank u....Ya I tried them but ,getting Access Denied Error..
-
Thank u....Ya I tried them but ,getting Access Denied Error..
Hi.. Now I could call the methods... I changed the Authentication level as NONE in the DCOM configuration... Its working fine.. Thank u ... :)
modified on Wednesday, April 15, 2009 6:28 AM
-
RevathiRamakumar wrote:
HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method...
That's odd... If you're able to successfully create the server and get a valid pointer to the interface, I cannot see how you could get an access violation making the call. It feels like there's some kind of mismatch between the server, typelib and client. If you have changed from an IDispatch-derived interface to an IUnknown-derived, the virtual table the client tries to use may be out of sync. That's why I suggested that you should unregister all and rebuild from scratch. How is your interface declared in the IDL-file? It should be something like this:
[
object,
uuid( xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ),
oleautomation,
helpstring( "IGetStatus interface" ),
]
interface IGetStatus : IUnknown
{
HRESULT GetBeat( [out] BSTR* pbstrTheBeat );
HRESULT GetCPU( [out] unsigned long* pulCpuLoad );
HRESULT GetMemory( [out] unsigned long* pulMemory );
};Also make sure in the client that the
IGetStatus
interface, declared in the complier generated header file, only containsQueryInterface()
,AddRef()
,Release()
,GetBeat()
,GetCPU()
andGetMemory()
. Try using one of the other interface functions since it's more straight forward with integer values and you don't have to worry about string obscurities. When you get that working you can continue withIGetStatus::GetBeat()
."It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknownHi Mr.Roger I got it working after changing the Authentication level to NONE in dcomcnfg...Initially it was dEFAULT after changing it to NONE its working fine.. Thank u... :)