Click here to Skip to main content
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 5: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
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 6 Mar 2012
Copyright © CodeProject, 1999-2014
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