SeeminglyScience / EditorServicesCommandSuite

Collection of editor commands for use in PowerShell Editor Services.
Other
152 stars 13 forks source link

Error importing module #33

Closed dsolodow closed 4 years ago

dsolodow commented 5 years ago

Windows 10 1809 x64 Visual Studio Code 1.30.1 PowerShell Extension 1.10.2

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) At C:\Users\dsolodow\Documents\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.4.0\EditorServicesCommandSuite.psm1:22 char:1

At C:\Users\dsolodow\Documents\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.4.0\Classes\Renderers.ps1:62 char:21

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) At C:\Users\dsolodow\Documents\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.4.0\EditorServicesCommandSuite.psm1:24 char:1

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) At C:\Users\dsolodow\Documents\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.4.0\EditorServicesCommandSuite.psm1:25 char:1

dsolodow commented 5 years ago

So it looks like this is connected to having non-alphanumeric characters in the path to the module. Specifically a dash and a comma (MyDocs redirected to OneDrive for Business)

SeeminglyScience commented 5 years ago

@dsolodow Very interesting, thanks for reporting this!

When you get a chance could you get the call stack for the first error?

  1. Force import the module Import-Module EditorServicesCommandSuite -Force
  2. Find the error index in $Error (e.g. if it was the last error it would be $Error[0])
  3. Run $Error[0].Exception.GetBaseException() | Format-List * -Force where the 0 in $Error[0] is the index found in step 2
SeeminglyScience commented 5 years ago

Also might be worth seeing if it works in the latest PowerShell Core. I vaguely recall there was some issues with how the type gen worked with unexpected characters in source paths.

dsolodow commented 5 years ago

PowerShell Core 6.1.1 works fine, but WindowsPowerShell gives the error.

Message : The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) FileName : FusionLog : Data : {System.Management.Automation.Interpreter.InterpretedFrameInfo} InnerException : TargetSite : Void nInit(System.Reflection.RuntimeAssembly ByRef, Boolean, Boolean) StackTrace : at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent) at System.Reflection.AssemblyName..ctor(String assemblyName) at System.Management.Automation.Language.TypeDefiner.DefineTypes(Parser parser, Ast rootAst, TypeDefinitionAst[] typeDefinitions) at System.Management.Automation.Language.Compiler.DefinePowerShellTypes(Ast rootForDefiningTypes, TypeDefinitionAst[] typeAsts) at System.Management.Automation.Language.Compiler.GenerateTypesAndUsings(ScriptBlockAst rootForDefiningTypesAndUsings, List1 exprs) at System.Management.Automation.Language.Compiler.CompileSingleLambda(ReadOnlyCollection1 statements, ReadOnlyCollection1 traps, String funcName, IScriptExtent entryExtent, IScriptExtent exitExtent, ScriptBlockAst rootForDefiningTypesAndUsings) at System.Management.Automation.Language.Compiler.CompileNamedBlock(NamedBlockAst namedBlockAst, String funcName, ScriptBlockAst rootForDefiningTypes) at System.Management.Automation.Language.Compiler.VisitScriptBlock(ScriptBlockAst scriptBlockAst) at System.Management.Automation.Language.Compiler.Compile(CompiledScriptBlockData scriptBlock, Boolean optimize) at System.Management.Automation.CompiledScriptBlockData.ReallyCompile(Boolean optimize) at System.Management.Automation.CompiledScriptBlockData.CompileUnoptimized() at System.Management.Automation.CompiledScriptBlockData.Compile(Boolean optimized) at System.Management.Automation.DlrScriptCommandProcessor.Init() at System.Management.Automation.CommandDiscovery.CreateCommandProcessorForScript(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useNewScope, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.CreateScriptProcessorForSingleShell(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useLocalScope, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable1 useLocalScope, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable1 useLocalScope) at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource) at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) HelpLink : Source : mscorlib HResult : -2146234297

SeeminglyScience commented 4 years ago

Fixed with v1.0.0-beta1

Install-Module EditorServicesCommandSuite -Scope CurrentUser -AllowPrerelease -Force