Powershell New-WebApplication

后端 未结 2 1438
Happy的楠姐
Happy的楠姐 2020-12-05 17:51
[Void][Reflection.Assembly]::LoadWithPartialName(\"Microsoft.Web.Administration\")

New-WebApplication -Name \'testApp\' -Site \'Default Web Site\' -PhysicalPath c:\         


        
相关标签:
2条回答
  • 2020-12-05 18:13

    I had the exact same problem because I was calling the wrong version of PowerShell from my program. I'm not sure about this but I think when you have a x86 program it calls the x86 version of PowerShell, which fails.

    To specifically use the 32-bit version, call this one from your program:

    C:\Windows\SysWoW64\WindowsPowerShell\v1.0\powershell.exe
    

    To use the 64-bit version (on a 64-bit OS), call this one from your program:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    

    Using C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exe from within a 32bit process will give you the 64bit powershell. Using it from within a 64bit process will give you a file-not-found error.

    0 讨论(0)
  • 2020-12-05 18:29

    Changing Platform target to "x64" in project solution build properties worked for me:

    screenshot of configuration page

    0 讨论(0)
提交回复
热议问题