Я наткнулся на различные решения для этого по сети, например,
One. Тем не менее, я не могу заставить их работать.
Я сохраняю код C# в файл .cs и когда я запускаю Add-Type в PS, с путем к файлу .cs, я получаю много ошибок, таких как Следующее: < /p>
Код: Выделить всё
Add-Type: (51,6): error CS0246: The type or namespace name 'ResourceExposureAttribute' could not be found (are you missing a using directive or an assembly reference?)
[ResourceExposure(ResourceScope.None)]
^
Add-Type: (51,6): error CS0246: The type or namespace name 'ResourceExposure' could not be found (are you missing a using directive or an assembly reference?)
[ResourceExposure(ResourceScope.None)]
^
Add-Type: (52,6): error CS0246: The type or namespace name 'SuppressUnmanagedCodeSecurityAttribute' could not be found (are you missing a using directive or an assembly reference?)
[SuppressUnmanagedCodeSecurity]
^
Add-Type: (52,6): error CS0246: The type or namespace name 'SuppressUnmanagedCodeSecurity' could not be found (are you missing a using directive or an assembly reference?)
[SuppressUnmanagedCodeSecurity]
^
Add-Type: (51,23): error CS0103: The name 'ResourceScope' does not exist in the current context
[ResourceExposure(ResourceScope.None)]
^
Add-Type: (37,6): error CS0246: The type or namespace name 'ResourceExposureAttribute' could not be found (are you missing a using directive or an assembly reference?)
[ResourceExposure(ResourceScope.None)]
^
Add-Type: (37,6): error CS0246: The type or namespace name 'ResourceExposure' could not be found (are you missing a using directive or an assembly reference?)
[ResourceExposure(ResourceScope.None)]
^
Add-Type: (38,6): error CS0246: The type or namespace name 'SuppressUnmanagedCodeSecurityAttribute' could not be found (are you missing a using directive or an assembly reference?)
[SuppressUnmanagedCodeSecurity]
Подробнее здесь: https://stackoverflow.com/questions/794 ... r-net-core