Reputation: 3183
There is a powershell script that gets called from asp.net . The powershell basically connects to Windows Azure Module.
When I debug the asp.net from VS it gets hosted in IIs-express and the powershell script runs as expected. But when the website is hosted in IIS, the below exception is being thrown
System.Management.Automation.InvalidPowerShellStateException occurred
HResult=-2146233087
Message=Microsoft.Online.Administration.Automation.MicrosoftOnlineException: Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.
Microsoft.Online.Administration.Automation.MicrosoftOnlineException: You must call the Connect-MsolService cmdlet before calling any other cmdlets.
Server stack trace:
at Microsoft.Online.Administration.Automation.BecWebServiceInspector.BeforeSendRequest(Message& request, IClientChannel channel)
at System.ServiceModel.Dispatcher.ImmutableClientRuntime.BeforeSendRequest(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.PrepareCall(ProxyOperationRuntime operation, Boolean oneway, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IProvisioningWebService.GetRoleByName(GetRoleByNameRequest request)
at ProvisioningWebServiceClient.GetRoleByName(GetRoleByNameRequest request)
System.Management.Automation.ParameterBindingException: Cannot bind parameter 'RoleObjectId' to the target. Exception setting "RoleObjectId": "Object reference not set to an instance of an object." ---> System.Management.Automation.SetValueInvocationException: Exception setting "RoleObjectId": "Object reference not set to an instance of an object." ---> System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , Object , Object )
at System.Management.Automation.ReflectionParameterBinder.BindParameter(String name, Object value)
--- End of inner exception stack trace ---
at System.Management.Automation.ReflectionParameterBinder.BindParameter(String name, Object value)
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
--- End of inner exception stack trace ---
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Source=ManagementConsoleV2
StackTrace:
at ManagementConsoleV2.Structures.Lync_Online.PowershellWrapper.RunPowerShellScript(String userName, String plainPassword, PowerShellScriptType powerShellScriptType) in c:\Dev Team\Sameer\Trunk\Web\ManagementConsoleV2\Structures\Lync Online\PowershellWrapper.cs:line 64
InnerException:
When the application is run in IIS-express, the process runs in 32 bit mode. I have also hosted the application in both 32 bit/64 bit mode threadpool in IIS but getting the same error both time.
Upvotes: 0
Views: 349
Reputation: 3183
In IIS Go to advanced settings of the application thread pool where your site is set to run in and Set Load user Profile : true
Upvotes: 1