Click here to Skip to main content
13,000,636 members (57,037 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i am calling powershell script using,C#,on powershell prompt.when i run application using visual studio its works fine on same system,but when i host same website in iis on same system it gives error.

means script unable to access to data error after hosting site in iis is:

You cannot call a method on a null-valued expression.At C:\shutdown.ps1:17 char:37+ $result = $vmshut.InitiateShutdown <<<< ("$true","no comment") + CategoryInfo : InvalidOperation: (InitiateShutdown:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull unable to shutdown wintest
Posted 5-Mar-12 4:23am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

sure you load the correct bit-wise version of PowerShell. If you're running the 64 bit version then you'll get the exception

Could you verify using the x86 powershell console as
[System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" )

rather than
prateekfgiet 6-Mar-12 0:08am
Please suggest me where i have to update [System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" )
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

i have resolved this problem doing some changes in iis

in iis application pool
coose advance setting --> in process model --> change identity from applicationippool to local system.

Thanks all

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 6 Mar 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100