无法引用之前工作的Dll [英] Can not reference a Dll that worked earlier

查看:392
本文介绍了无法引用之前工作的Dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以编程方式更改终端服务设置。 我了解到您必须使用tsuserex.dll 。作为c#我跑tsuserex通过tlbimp和创建TSUSEREXLib.dll然后注册它与regasm。我得到它的工作,并写了一个框架程序与它作为一个概念的prof。但是我今天在我运行程序时做了一些修改,得到错误



无法将类型为System .__ ComObject的COM对象转换为接口类型TSUSEREXLib.IADsTSUserEx '。此操作失败,因为COM组件上的QueryInterface调用与IID'{C4930E79-2989-4462-8A60-2FCF2F2955EF}'的接口失败,原因是以下错误:没有此类接口支持(来自HRESULT的异常:0x80004002(E_NOINTERFACE))

  IADsTSUserEx iad = 



< (IADsTSUserEx)((DirectoryEntry)user.GetUnderlyingObject())。NativeObject;

这个确切的行在测试项目中工作正常。我知道用户是一个有效的UserPrincipal,Googleing我发现这通常只是需要dll重新注册,但即使卸载和重新加载它后仍然不会工作。

解决方案

我知道这是一个旧线程,但由于我最近遇到麻烦找到所有必要的步骤,让终端服务组件在Windows 7上工作,我想分享我发现的。我认为以下步骤比从服务器复制tsuserex.dll并尝试注册它更可靠。



根据我的理解,在任何操作系统上,你需要远程服务器管理工​​具(RSAT),以便以编程方式修改用户帐户的终端服务属性。在某些版本的Windows上,这需要下载。但是在Windows 7上,RSAT已经安装。



但是您可能需要使用控制面板(appwiz.cpl)中的配置选项启用它。在打开或关闭Windows功能转到远程服务器管理工​​具,然后确保选中远程桌面服务工具。



)我能够通过PowerShell使用tsuserex.dll的组件(例如,Set-QADUser -Identity testUser -TsHomeDirectoryc:\tshome),并通过在Visual Studio 2010中添加一个引用(tsexusrm 1.0类型库)。


I am trying to change the Terminal Services settings programmaticly. I learned that you must use tsuserex.dll. Being c# i ran tsuserex through tlbimp and created TSUSEREXLib.dll then registered it with regasm. I got it working and wrote a framework program with it as a prof of concept. However today after I made some changes when I run my program I get the error

Unable to cast COM object of type 'System.__ComObject' to interface type 'TSUSEREXLib.IADsTSUserEx'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C4930E79-2989-4462-8A60-2FCF2F2955EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

it thows the exception on the line

IADsTSUserEx iad = (IADsTSUserEx)((DirectoryEntry)user.GetUnderlyingObject()).NativeObject;

This exact line worked fine in the test project. I know user is a valid UserPrincipal, Googleing I found this is usually just needs the dll re-registered, but even after unloading and reloading it it still will not work. What am I missing to cause my dll to stop working.

解决方案

I know this is an old thread but since I had trouble recently finding all the required steps to get the Terminal Services components working on Windows 7, I wanted to share what I found. I think the steps below are more reliable than copying the tsuserex.dll from a server and trying to register it.

From what I understand, on any operating system you need Remote Server Administration Tools (RSAT) installed in order to modify Terminal Services attributes of a user account programmatically. On some versions of Windows this requires a download. But on Windows 7, RSAT is already installed.

But you may need to enable it using the configuration options in Control Panel (appwiz.cpl). Under "Turn Windows features on or off" goto "Remote Server Administration Tools" then ensure that "Remote Desktop Services Tools" is checked.

After I did this (and rebooted) I was able to use the components from tsuserex.dll via PowerShell (e.g., Set-QADUser -Identity testUser -TsHomeDirectory "c:\tshome"), and by adding a reference in Visual Studio 2010 (to "tsexusrm 1.0 Type Library").

这篇关于无法引用之前工作的Dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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