Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
C#
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
Updated 6-Jun-12 19:43pm
v3

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
 
Share this answer
 
Comments
nairnishitha 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.
here's some code comments, I've referred to a LOT in recent years ;)

/*<br />
<br />
If you are reading this because you're trying to get a DCOM component working, and you're trying to establish why THIS one<br />
works, and yours doesn't, you've come to the right place ...<br />
<br />
Fundamentally, DCOM works thru the application of settings in the HKLM/APPID reg branch<br />
<br />
CLSIDs are connected to APPIDs thru the val APPID in the HKLM/CLSID branch<br />
<br />
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<br />
<br />
Additionally, running DCOMCNFG confuses the issue because *IT* creates glue in lieu of what ATL didn't, and gets it wrong<br />
<br />
You need to mod your object's RGS file to include<br />
                val AppID = s '%APPID%'<br />
<br />
You need to supplement your server's RGS to include<br />
                // for exes<br />
                NoRemove AppID<br />
                {<br />
                    '%APPID%' = s '<your description of your application>'<br />
                    '<your exe's name>.exe'<br />
                    {<br />
                        val AppID = s '%APPID%'<br />
                    }<br />
                }<br />
                // for dlls<br />
                NoRemove AppID<br />
                {<br />
                    '%APPID%' = s '<your description of your application>'<br />
                    {<br />
                        val DllSurrogate = s ''<br />
                    }<br />
                    '<your exe's name>.dll'<br />
                    {<br />
                        val AppID = s '%APPID%'<br />
                    }<br />
                }<br />
<br />
<br />
%APPID% is a known token in the RGS registrar mechanism<br />
<br />
NOW, you can use dcomcnfg to configure your object, and it should work<br />
<br />
errors you may get<br />
<br />
ACCESSDENIED - the user trying to launch the com object must be given launch permissions *AND* be included in the machine's Access Limit<br />
MISSINGMODULE - probably missing the proxyStub dll<br />
<br />
<br />
*/


Hope it helps
 
Share this answer
 
Comments
nairnishitha 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900