简体   繁体   English

CS50542 和 CS0103 使用代码转换器将包含 wpf 控件的 vb 项目转换为 c#

[英]CS50542 and CS0103 adter converting a vb project containing a wpf control to c# using code converter

I have a vb project that contains a wpf control I am using Code Converter to do the conversion After running the converter and building I get the following buid errors我有一个包含 wpf 控件的 vb 项目我正在使用代码转换器进行转换运行转换器并构建后,我收到以下 buid 错误

Error   CS0542  'SpellControl': member names cannot be the same as their enclosing type  

and

Error   CS0103  The name 'InitializeComponent' does not exist in the current context

The xaml is xaml 是

<UserControl x:Class="SpellControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="400">
    <Grid>
        <TextBox x:Name="textSpell" SpellCheck.IsEnabled="True" Language="en-AU" FontSize="14" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Loaded="textSpell_Loaded">
        </TextBox>
    </Grid>
</UserControl>

I had to edit the UserControl code to add the namespace我必须编辑 UserControl 代码以添加命名空间

<UserControl x:Class="MyProjectNamespace.SpellControl"

Where MyProjectNamespace is the Default Namespace in the project application tab.其中 MyProjectNamespace 是项目应用程序选项卡中的默认命名空间。

This resolved the CS0103 error这解决了 CS0103 错误

To resolve the CS50542 error I just had to remove the generated control initializer要解决 CS50542 错误,我只需删除生成的控件初始化程序

public partial class SpellControl
{
    public SpellControl()
    {
        InitializeComponent();
    }

    //public void SpellControl()
    //{
    //}

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

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