Title: Using external types / classes in Custom PowerShell Classes (v5) results in Parsing Error · Issue #2074 · PowerShell/PowerShell · GitHub
Open Graph Title: Using external types / classes in Custom PowerShell Classes (v5) results in Parsing Error · Issue #2074 · PowerShell/PowerShell
X Title: Using external types / classes in Custom PowerShell Classes (v5) results in Parsing Error · Issue #2074 · PowerShell/PowerShell
Description: The Issue I am trying to create a PowerShell-Project with my own custom PowerShell-Classes. I use explicit type defintion for all attributes of my custom classes. For all integrated .Net-Classes there is now problem, but for other classe...
Open Graph Description: The Issue I am trying to create a PowerShell-Project with my own custom PowerShell-Classes. I use explicit type defintion for all attributes of my custom classes. For all integrated .Net-Classes th...
X Description: The Issue I am trying to create a PowerShell-Project with my own custom PowerShell-Classes. I use explicit type defintion for all attributes of my custom classes. For all integrated .Net-Classes th...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/2074
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using external types / classes in Custom PowerShell Classes (v5) results in Parsing Error","articleBody":"\u003c!--\n\nIf it is a bug report:\n- make sure you are able to repro it on the latest released version. \nYou can install the latest version from https://github.com/PowerShell/PowerShell/releases\n- Search the existing issues.\n- Refer to the [FAQ](../docs/FAQ.md).\n- Refer to the [known issues](../docs/KNOWNISSUES.md).\n- Fill out the following repro template\n\nIf it's not a bug, please remove the template and elaborate the issue in your own words.\n-->\n## The Issue\n\nI am trying to create a PowerShell-Project with my own custom PowerShell-Classes. \nI use explicit type defintion for all attributes of my custom classes. For all integrated .Net-Classes there is now problem, but for other classes (for example external dll) it does not work.\nIt seems like, that you have to create a Wrapper script which loads the dll / Imports the module and afterwards starts the actual script project (with custom classes) by dotsourcing.\n\nUnfortunately this workaround (Wrapper-Script) does not work out in my scenario --> A automation / orchestration engine only accepts one script...\n\nSo is there a way to fix this? The Parser should not throw an error, as you declare (using statement) that you will use classes out of this namespace. If there is something wrong with the class itself.. .this should be a runtime exception, or am I wrong?\n## Steps to reproduce\n\n``` powershell\nusing namespace Microsft.ActiveDirectory.Management\n#These two do not work, too \n#using module ActiveDirectory\n#Import-Module ActiveDirectory\n\nclass Test\n{\n [Microsoft.ActiveDirectory.Management.ADDomain] $domain;\n\n}\n ...\n```\n## Expected behavior\n\nno Error Message\n## Actual behavior\n\n``` powershell\nAt line:9 char:6\n+ [Microsoft.ActiveDirectory.Management.ADDomain] $domain;\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nUnable to find type [Microsoft.ActiveDirectory.Management.ADDomain].\n + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException\n + FullyQualifiedErrorId : TypeNotFound\n```\n## In this case with an integrated .NET class it perfectly works.\n\n``` powershell\nusing namespace System.DirectoryServices.ActiveDirectory \n\nClass Test \n{ \n [Domain] $dom = [Domain]::GetCurrentDomain() \n} \n```\n","author":{"url":"https://github.com/Lindmeier","@type":"Person","name":"Lindmeier"},"datePublished":"2016-08-26T09:49:14Z","url":"https://github.com/PowerShell/PowerShell/issues/2074"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a77b56ac-3173-c42c-eb0c-84c51996a290 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAC8:26A4FF:F2986:154B6B:6AFDAB40 |
| html-safe-nonce | 15566f5a7f8cac4798e41d73d0629ee9634a13b837468581e2752ee3510016ed |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUM4OjI2QTRGRjpGMjk4NjoxNTRCNkI6NkFGREFCNDAiLCJ2aXNpdG9yX2lkIjoiNDQ4NDI2ODM4MDc5ODE2Nzg3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d584c0df6abbea8a778356143f642ff9c3c44a04a555984ba205a3c32da658d5 |
| hovercard-subject-tag | issue:173413624 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/2074/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dfa57e8f45178f0d0775e131dfd61e6ae750665f1fd27f4db37f59afdebd69e2/PowerShell/PowerShell/issues/2074 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dfa57e8f45178f0d0775e131dfd61e6ae750665f1fd27f4db37f59afdebd69e2/PowerShell/PowerShell/issues/2074 |
| og:image:alt | The Issue I am trying to create a PowerShell-Project with my own custom PowerShell-Classes. I use explicit type defintion for all attributes of my custom classes. For all integrated .Net-Classes th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Lindmeier |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0ddf53eb35c87f1f8df13dbf75c3bdadbfc6e969 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width