programing

에 Powershell v2.0을 내장하고 있습니다.Windows 8 RTM의 NET 앱

newnotes 2023. 9. 7. 22:00
반응형

에 Powershell v2.0을 내장하고 있습니다.Windows 8 RTM의 NET 앱

Windows 7(윈도우 7)에서 업그레이드하기 전에 호스트된 파워셸 스크립트를 실행하려고 하면 다음 오류가 발생합니다. 이 오류가 발생하지 않습니다.

확장 형식 데이터 파일을 로드하는 중에 다음 오류가 발생했습니다. Microsoft.파워쉘.Core, C:\Windows\SysWOW64\Windows PowerShell\v1.0\types.ps1xml(2977) : "System" 유형에 오류가 있습니다.보안.액세스 제어.개체 보안":예외:getter 메서드는 public, non void, static이어야 하며 PSObject 유형의 매개 변수가 하나 있어야 합니다.마이크로소프트.파워쉘.Core, C:\Windows\SysWOW64\Windows PowerShell\v1.0\types.ps1xml(2984) : "System" 유형에 오류가 있습니다.보안.액세스 제어.개체 보안":예외:getter 메서드는 public, non void, static이어야 하며 PSObject 유형의 매개 변수가 하나 있어야 합니다.마이크로소프트.파워쉘.Core, C:\Windows\SysWOW64\Windows PowerShell\v1.0\types.ps1xml(2991) : "System" 유형에 오류가 있습니다.보안.액세스 제어.개체 보안":예외:getter 메서드는 public, non void, static이어야 하며 PSObject 유형의 매개 변수가 하나 있어야 합니다.마이크로소프트.파워쉘.Core, C:\Windows\SysWOW64\Windows PowerShell\v1.0\types.ps1xml(2998) : "System" 유형에 오류가 있습니다.보안.액세스 제어.개체 보안":예외:getter 메서드는 public, non void, static이어야 하며 PSObject 유형의 매개 변수가 하나 있어야 합니다.마이크로소프트.파워쉘.Core, C:\Windows\SysWOW64\Windows PowerShell\v1.0\types.ps1xml(3005) : "System" 유형에 오류가 있습니다.보안.액세스 제어.개체 보안":예외:getter 메서드는 public, non void, static이어야 하며 PSObject 유형의 매개 변수가 하나 있어야 합니다.

App.config에서 다음을 적용했습니다.

<dependentAssembly>
  <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
  <publisherPolicy apply="no" />
</dependentAssembly>

무엇이 문제가 될 수 있습니까?

해결책은 시스템에만 블록을 추가하는 것이 아니라 다음을 수행하는 것입니다.관리.내가 읽은 게시물에서 제시한 자동화, 당신은 모든 참조 PS 어셈블리에 대해 하나를 추가해야 합니다.

  <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
            <publisherPolicy apply="no" />
          </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" />
          <publisherPolicy apply="no" />
        </dependentAssembly>
        </assemblyBinding>
    </runtime>

VS 2015 업데이트 3에서도 같은 문제가 있었습니다.

폴더를 제거해야 합니다.

%APPDATA%\Local\Microsoft\VisualStudio\

다음 항목에 추가합니다.

c:\Users\%username%\AppData\Local\Microsoft\VisualStudio\14.‌​0\devenv.exe.config

섹션:

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

다음 줄

<dependentAssembly>
  <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
  <publisherPolicy apply="no" />
</dependentAssembly>

<dependentAssembly>
  <assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" />
  <publisherPolicy apply="no" />
</dependentAssembly>

<dependentAssembly>
  <assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" />
  <publisherPolicy apply="no" />
</dependentAssembly>

<dependentAssembly>
  <assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" />
  <publisherPolicy apply="no" />
</dependentAssembly>

<dependentAssembly>
  <assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" />
  <publisherPolicy apply="no" />
</dependentAssembly>

<dependentAssembly>
  <assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" />
  <publisherPolicy apply="no" />
</dependentAssembly>

해결책을 찾느라 이틀을 잃었어요감사합니다 MS :-/

위의 답변은 저에게 효과가 없었습니다. %APPDATA%를 제거하여 문제를 해결했습니다.\Local\Microsoft\VisualStudio\폴더.

Upon restarting VS this folder is recreated and the package manager console works again. A little crude but it does the job.

After trying the solution in the accepted answer and getting tired of Visual Studio resetting the file, I reinstalled VS 2015 from scratch and haven't had the problem since. If you find the issue persists, the nuclear option is definitely worth a try.

Install the appropriate version of PowerShell for your OS:

  • Windows XP SP2 / Vista / 2003 / 2008 - PowerShell v1.0
  • Windows XP SP3 / Vista SP1 / 7 / 2003 SP2 / 2008 R2 - PowerShell v2.0
  • Windows 7 SP1 / 8 / 2008 SP1 / 2008 R2 SP1 / 2012 - PowerShell v3.0
  • Windows 7 SP1 / 8.1 / 2008 R2 SP1 / 2012 / 2012 R2 - PowerShell v4.0
  • Windows 7 SP1 / 8.1 / 2008 R2 SP1 / 2012 / 2012 R2 - PowerShell v5.0 (as part of Windows Management Framework (WMF) 5.0)

ReferenceURL : https://stackoverflow.com/questions/12638289/embedding-powershell-v2-0-in-net-app-on-windows-8-rtm

반응형