简体   繁体   English

我在VS2017中启动的项目无法在VS2019上构建:错误CS1061

[英]Project that i started in VS2017 wont build on VS2019: error CS1061

project I started in visual studio 2017 gets this error when I try to run it in visual studio 2019 : 我在visual studio 2017启动的项目尝试在visual studio 2019运行时遇到此错误:

Error CS1061 'SimpleViewWindow' does not contain a definition for 'ConnectRDP_Clicked' and no accessible extension method 'ConnectRDP_Clicked' accepting a first argument of type 'SimpleViewWindow' could be found (are you missing a using directive or an assembly reference?) VPN_Switch C:\\Users\\Tommy\\source\\repos\\Soft VPN\\VPN_Switch\\Windows\\SimpleViewWindow.xaml 错误CS1061'SimpleViewWindow'不包含'ConnectRDP_Clicked'的定义,并且找不到可以接受的扩展方法'ConnectRDP_Clicked'接受类型为'SimpleViewWindow'的第一个参数(您是否缺少using指令或程序集引用?)VPN_Switch C: \\ Users \\ Tommy \\ source \\ repos \\ Soft VPN \\ VPN_Switch \\ Windows \\ SimpleViewWindow.xaml

this error occurs on about 11 other buttons as well. 此错误也发生在大约11个其他按钮上。

I have checked that if I add a new event for the buttons that have this error, it does add the new event handler to the mainwindow.xaml.cs as it should. 我检查了是否为有此错误的按钮添加了新事件,是否确实将新事件处理程序添加到了mainwindow.xaml.cs中。

I have also tried to rebuild as other solutions suggested. 我还尝试按照其他解决方案建议进行重建。

XAML XAML

<MenuItem Header="File">
                        <MenuItem Header="{Binding Path=ButtonClickAction}" Click="Connect_Clicked" />
                        <MenuItem Header="Connect to PC" Click="ConnectRDP_Clicked" />
                        <MenuItem Header="Edit" Click="EditVPN_Clicked" />
                        <Separator />
                        <MenuItem Header="New"   Click="NewEntry_Clicked" />
                        <MenuItem Header="Import" Foreground="#FF999999" />
                        <Separator />
                        <MenuItem Header="Create Shortcut" Foreground="#FF999999" />
                        <Separator />
                        <MenuItem Header="Delete" Click="Remove_Clicked" />                        
                        <Separator />
                        <MenuItem Header="Exit" Click="Exit_Clicked" />
                    </MenuItem>

C# C#

private void Connect_Clicked(object sender, RoutedEventArgs e)
{
    if (dg_DataGrid.SelectedItem != null)
    {
        ConnectionHandeler((VPN)dg_DataGrid.SelectedItem);
    }
}

private void ConnectRDP_Clicked(object sender, RoutedEventArgs e)
{
      ConnectRDP();
}

private void EditVPN_Clicked(object sender, RoutedEventArgs e)
{
      EditVPNWindow E_Window = new EditVPNWindow();
      E_Window.Show();
}

private void NewEntry_Clicked(object sender, RoutedEventArgs e)
{
     AddVPNWindow window = new AddVPNWindow();
     window.Show();
}

when running the program on VS 2017 it works as it should, so I expect it to be some problem with visual studio 2019 , some path that isn't correct or something like that. VS 2017上运行该程序时,它应该可以正常工作,因此我希望它是visual studio 2019问题,某些路径不正确或类似的问题。

Please try changing private void ConnectRDP_Clicked to protected void ConnectRDP_Clicked . 请尝试将private void ConnectRDP_Clicked更改为protected void ConnectRDP_Clicked You may do this for all similar event handlers. 您可以对所有类似的事件处理程序执行此操作。

Solved the problem on my own. 我自己解决了这个问题。 was a simple case of temporary blindness. 是暂时失明的简单案例。 the problem was that i have the same toolbar on another window and that window did not have the methods for the buttons like it had in mainwindow. 问题是我在另一个窗口上有相同的工具栏,并且该窗口没有像mainwindow一样的按钮方法。 Sorry for wasting peoples time :) 很抱歉浪费人们的时间:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM