Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i am calling powershell script using asp.net,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

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
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
 
Share this answer
 
Comments
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" )
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900