Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# COM COM+
Hi,
 
I have a WPFApplication coded in c# that access a COM component. My machine(client) and the COM Server machine have Windows 7 OS. And both on same domain. I tried to create an instance of the com component with below code and it gave me no error
IPDSIntf test; 
string clsId = "85689616-277B-4E00-9A5E-19AD78E7E0E2";
var type = Type.GetTypeFromCLSID(new Guid(clsId), MachineName, true);
                var COMObject = Activator.CreateInstance(type);
                test = (IPDSIntf)COMObject;
Now when I call any method in the COM. say test.Connect(clientId, errorCode), I am getting exception 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))'.
 
Have set many permission, gave admin privilege to my user account on the server machine, added mu account to 'Distributed COM Users' group etc... But still getting same issue.
If I have the COM component also locally, i.e. , client and server in same machine, I get no such error.
 
I am running out of time to fix it and have already spent 3 days on the same, googling. But no luck.
 
One more thing, is I could not see my COM in DCOMCNFG, means it is not registered? What could be the reason for it. I believe all COM component in machine will be registered in component services. Need some clarification on this too as I doubt it has some relation with my issue.
 

Thanks In advance,
Nishitha
Posted 6-Jun-12 1:48am
Edited 6-Jun-12 20:43pm
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
please have a look at my hints a few weeks ago, maybe it works for you.
 
Retrieve Operating system details of a remote computer using IP address[^]
 
Regards
  Permalink  
Comments
nairnishitha at 6-Jun-12 8:30am
   
I have copied the code mentioned in above link and created a ManagementScope object(for the remote machine) and set privilege. It gave me no exception. But still my Connect() method is giving the very same error.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

here's some code comments, I've referred to a LOT in recent years Wink | ;)
 
/*
 
If you are reading this because you're trying to get a DCOM component working, and you're trying to establish why THIS one
works, and yours doesn't, you've come to the right place ...
 
Fundamentally, DCOM works thru the application of settings in the HKLM/APPID reg branch
 
CLSIDs are connected to APPIDs thru the val APPID in the HKLM/CLSID branch
 
When creating a ATL server object, be that exe, service or dll, the wizard for (at least vs2010) doesn't create all the right glue
 
Additionally, running DCOMCNFG confuses the issue because *IT* creates glue in lieu of what ATL didn't, and gets it wrong
 
You need to mod your object's RGS file to include
val AppID = s '%APPID%'
 
You need to supplement your server's RGS to include
// for exes
NoRemove AppID
{
'%APPID%' = s '<your description of your application>'
'<your exe's name>.exe'
{
val AppID = s '%APPID%'
}
}
// for dlls
NoRemove AppID
{
'%APPID%' = s '<your description of your application>'
{
val DllSurrogate = s ''
}
'<your exe's name>.dll'
{
val AppID = s '%APPID%'
}
}
 

%APPID% is a known token in the RGS registrar mechanism
 
NOW, you can use dcomcnfg to configure your object, and it should work
 
errors you may get
 
ACCESSDENIED - the user trying to launch the com object must be given launch permissions *AND* be included in the machine's Access Limit
MISSINGMODULE - probably missing the proxyStub dll
 

*/

 
Hope it helps
  Permalink  
Comments
nairnishitha at 28-Jun-12 3:43am
   
Thanks barneyman for the detailed reply. I did not have to follow the steps mentioned as the client's machine had the component available in DCOMCNFG and we had to test the app there alone and it worked perfectly there.
 
But your suggestion seems to be a good guide for those having similar issue.
 
Thanks Again
Nishitha

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 200
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 7 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100