question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PS Class type not found error with using module

See original GitHub issue

System Details

System Details Output

### VSCode version: 1.47.3 91899dcef7b8110878ea59626991a18c8a6a1b3e x64

### VSCode extensions:
Damien.autoit@1.0.5
DavidAnson.vscode-markdownlint@0.36.2
eamodio.gitlens@10.2.2
fernandoescolar.vscode-solution-explorer@0.3.10
GrapeCity.gc-excelviewer@3.0.39
jmrog.vscode-nuget-package-manager@1.1.6
mechatroner.rainbow-csv@1.7.1
mhutchie.git-graph@1.25.0
ms-dotnettools.csharp@1.22.1
ms-mssql.mssql@1.9.0
ms-python.python@2020.7.96456
ms-vscode-remote.remote-wsl@0.44.4
ms-vscode.cpptools@0.29.0
ms-vscode.powershell@2020.6.0
ms-vscode.powershell-preview@2020.7.0
redhat.vscode-xml@0.13.0
streetsidesoftware.code-spell-checker@1.9.0
zhuangtongfa.material-theme@3.8.5


### PSES version: 2.3.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.1.0-preview.5
PSEdition                      Core
GitCommitId                    7.1.0-preview.5
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

PS Class with using module statement throws type not found. If in the integrated PS console I run using module X and then remove and add back the using statements the error will away.

It looks as though VS code is not running the using statements while editing the script.

Expected Behaviour

Open a class file with types residing in a module and no type not found error is thrown.

Actual Behaviour

Type not found until manually running using statements in integrated console.

Attached Logs

Follow the instructions in the troubleshooting docs about capturing and sending logs.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ThomasNietocommented, Aug 12, 2020

Yeah, any edit seems to do.

1reaction
JustinGrotecommented, Nov 30, 2021

@andschwa @SeeminglyScience there currently is a situation where we get both the “unable to find type” and the PSScriptAnalyzer “Ignoring TypeNotFound” info. Maybe if we detect both of these we can silently suppress the error Problem and only present the information warning?

image

If so it may be worth reopening this issue to address.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Referencing assemblies inside PS classes causes "Unable to ...
NET assembly to be available when the module is parsed and prevents the "Unable to find type" error. Now armed with the new...
Read more >
Using Statement: Import PowerShell Classes from Modules
Using module imports classes from the root module (ModuleToProcess) of a script module or binary module. The Using statement does not ( ...
Read more >
How to write Powershell modules with classes - Stephanevg
When trying to instanciate the class, it will throw an error saying it didn't found the Type. Which really means that it couldn't...
Read more >
How to fix "The following module is missing from the file ...
I managed to remove errors caused by a couple of submodules in "VB to Drupal", which I somehow must have managed not to...
Read more >
New-Object (Microsoft.PowerShell.Utility)
The New-Object cmdlet creates an instance of a .NET Framework or COM object. You can specify either the type of a .NET Framework...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found