Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate why running cmdlets result in this error. For example -> node .\test.js Get-Process <- causes this error. While this works -> node .\test.js 'Get-Process | Out-String'. #6

Open
dfinke opened this issue Mar 14, 2013 · 9 comments
Labels

Comments

@dfinke
Copy link
Owner

dfinke commented Mar 14, 2013

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Process must exit before requested information can be determined.
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.get_ExitCode()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
   at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
   at ClrFunc.MarshalCLRToV8(Handle<v8::Value>* , Object netdata)
@cdhunt
Copy link

cdhunt commented Mar 20, 2013

I can't even get test.js to run, but does outputs.Select(pso => pso.BaseObject).ToList() strip of all of the ScriptProperties normally returned with Get-Process?

@dfinke
Copy link
Owner Author

dfinke commented Mar 20, 2013

what error do you get?

@cdhunt
Copy link

cdhunt commented Mar 20, 2013

C:\Users\hunt\Documents\GitHub\edge-powershell\samples\tryPowerShell\test.js:16
    if (error) throw error;
                     ^
System.AggregateException: One or more errors occurred. ---> System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'.
   at Edge.PS.EdgePowerShell.<InvokeScript>d__2.MoveNext() in c:\Users\chunt\Documents\GitHub\edge-powershell\src\Edge.PowerShell\Edge.PowerShell\EdgePowerShell.cs:line 36
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'.
   at Edge.PS.EdgePowerShell.<InvokeScript>d__2.MoveNext() in c:\Users\chunt\Documents\GitHub\edge-powershell\src\Edge.PowerShell\Edge.PowerShell\EdgePowerShell.cs:line 36<---

@dfinke
Copy link
Owner Author

dfinke commented Mar 20, 2013

Thanks for posting. I know nodejs got upgraded and edge had some fixes. May need to pull them over.

@cdhunt
Copy link

cdhunt commented Mar 20, 2013

FYI: tried on another machine with Node 0.8.14 and received the same error.I must be missing something.

@dfinke
Copy link
Owner Author

dfinke commented Mar 20, 2013

you need to set the $env:EDGE... variable. check the Invoke-PSNode.ps1

also are you running it from the tryPowerShell dir?
using
c:> node test.js

@dfinke
Copy link
Owner Author

dfinke commented Mar 20, 2013

Chris, found the issue, here's the write up #7 (comment)

@cdhunt
Copy link

cdhunt commented Mar 21, 2013

Thanks. I got everything running and stepped through the code. I have no ideas other than replacing JSON serialization in Edge with Json.Net which has worked well with PSObjects for me in the past.

@dfinke
Copy link
Owner Author

dfinke commented Mar 21, 2013

Terrific. I saw some info just the other day about folks switching to Json.Net. It was on my list.

Looking forward to playing with it.

Thanks
Doug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants