Показаны различия между двумя версиями страницы.
comment66 [2018/04/13 22:43] |
comment66 [2018/04/13 22:43] (текущий) |
||
---|---|---|---|
Строка 1: | Строка 1: | ||
+ | В [[Ax40 | ]] | ||
+ | In 4.0 we have added code access security (CAS) to the run-time. | ||
+ | So by | ||
+ | default most of the calls that are I/O or process bound demand | ||
+ | that the code | ||
+ | making the call has the right permission to make the I/O or | ||
+ | process boiund | ||
+ | call. Using a COM component is bound to a different process so | ||
+ | the runtime | ||
+ | demand that the code enforces the InteropPermission check and | ||
+ | checks if the | ||
+ | current user has the permission. | ||
+ | |||
+ | So you've got to create and assert this interopPermission in your | ||
+ | code just | ||
+ | before you make the COM call. Here's how you do it below: | ||
+ | |||
+ | ------------------------------------- | ||
+ | COM com; | ||
+ | InteropPermission permission = new | ||
+ | InteropPermission(InteropKind:: | ||
+ | ; | ||
+ | |||
+ | permission.assert(); | ||
+ | com = new COM(namespace.classname); | ||
+ | com.SomeMethod(); | ||
+ | CodeAccessPermission:: | ||
+ | -------------------------------------------- |