Click here to Skip to main content
11,568,180 members (38,159 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# PowerShell script
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 5-Mar-12 4:23am
Rate this: bad
good
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
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
  Permalink  
Comments
prateekfgiet at 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
good
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
  Permalink  

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

  Print Answers RSS


Advertise | Privacy | Mobile
Web04 | 2.8.150624.2 | Last Updated 6 Mar 2012
Copyright © CodeProject, 1999-2015
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