C#COM Interop,尝试访问远程服务器获取访问被拒绝的异常 [英] C# COM Interop, try to access remote server gets access denied exception

查看:113
本文介绍了C#COM Interop,尝试访问远程服务器获取访问被拒绝的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个用C#编码的WPFApplication,可以访问COM组件.我的机器(客户端)和COM Server机器具有Windows 7 OS.并且两者都在同一个域上.我尝试使用下面的代码创建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;


现在,当我在COM中调用任何方法时.说 test.Connect(clientId,errorCode),我收到异常"访问被拒绝. (来自HRESULT的异常:0x80070005(E_ACCESSDENIED))".

设置了许多权限,在服务器计算机上为我的用户帐户授予了管理员特权,将mu帐户添加到了分布式COM用户"组中,等等...但是仍然遇到相同的问题.
如果我在本地也有COM组件,即同一台计算机上的客户端和服务器,则不会出现此类错误.

我没有足够的时间来修复它,并且已经花了3天的时间在同一谷歌上搜索.但没有运气.

还有一件事,我在DCOMCNFG中看不到我的COM,这意味着它没有注册吗?这可能是什么原因.我相信机器中的所有COM组件都将在组件服务中注册.我对此也需要澄清,因为我怀疑它与我的问题有关系.


提前谢谢,
Nishitha


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

推荐答案



请在几周前看看我的提示,也许对您有用.

使用IP地址检索远程计算机的操作系统详细信息 [ ^ ]

关于
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


这里的一些代码注释,我近年来提到过很多;)

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


这篇关于C#COM Interop,尝试访问远程服务器获取访问被拒绝的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆