the document item has no code-behind file

Issue #127 resolved
thom created an issue

Hello,

I created a PowerShell WPF Window for the first time today. Unfortunately, I get the following error message in the properties of the button:

“The document item has no code-behind file. Add a code-behind file and a class definition before adding event handlers.”

(see picture attached)

What do I have to do to use the event handler?

Name                           Value                                                                                                                
----                           -----                                                                                                                
PSVersion                      5.1.17763.503                                                                                                        
PSEdition                      Desktop                                                                                                              
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                              
BuildVersion                   10.0.17763.503                                                                                                       
CLRVersion                     4.0.30319.42000                                                                                                      
WSManStackVersion              3.0                                                                                                                  
PSRemotingProtocolVersion      2.3                                                                                                                  
SerializationVersion           1.1.0.1                                                                                                              

PowerShell Tools for Windows Version 4.7.1

Comments (9)

  1. Dan Rayner

    Currently having the same issue.

    I have tried VS 2017 (15.9.13) and 2019 community editions.

    I can build and run the GUI but unable to add event handlers, I have named all controls and the main window.

  2. Dan Rayner

    I have found that if I run VS as admin I don’t run into this issue. Not sure if a permissions or profile issue.

  3. thom reporter

    Hello Dan,

    I must install my computer new.

    I have may problems with the poshtools.

    I want run the PowerShellProject1.ps1 as Script: [cid:image001.png@01D538B3.CF62AE70]

    I get this Error.

    [cid:image002.png@01D538AF.1DDA3690]

    If I run the Code within the PowerShell Interactive Window, all ok.

    [cid:image003.png@01D538B9.9E44EC80]

    Note: I must changed the PowerShell Execution Policy for the Interactive Window

    [cid:image004.png@01D538BA.0AA7A890]

    My Environment now:

    Microsoft Visual Studio Enterprise 2017 Version 15.9.14 VisualStudio.15.Release/15.9.14+28307.770 Microsoft .NET Framework Version 4.7.03190

    Installed Version: Enterprise

    C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

    MLGen Package Extension 1.0 MLGen Package Visual Studio Extension Detailed Info

    NuGet Package Manager 4.6.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

    PowerShell Pro Tools for Visual Studio 1.0 A set of tools for developing and debugging PowerShell scripts and modules in Visual Studio.

    ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

    ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

    ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

    System Center Visual Studio Authoring Extensions 1.1.0.0 System Center Visual Studio Authoring Extensions

    Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

    [cid:image005.png@01D538BA.1EC09DF0]

    Kind Regards

    Thomas

  4. Log in to comment