【问题标题】:Already definied InitalizeComponent and ambiguity between _contentLoaded已经定义了 InitializeComponent 和 contentLoaded 之间的歧义
【发布时间】:2014-12-28 11:53:21
【问题描述】:

我在 VS2012 的 c# 项目中收到有关 InitalizeComponent() 的错误。

type 已经定义了一个名为 initializecomponent 的成员

我决定尝试排除项目的那一部分,它可以工作。项目的其余部分都很好。当我再次添加项目的那部分时,没有发生 InitalizeComponent 错误,但我收到了一个错误:

_contentLoad 和 _contentLoad 之间的歧义

这是关于 DeleteCustomerForm,但 VS 显示它在 DeleteCustomerForm.g.i.cs 中(那个 g.i. 是什么意思?)。这是那部分代码:

    namespace PropertyManagementPoland.CustomerForms {


/// <summary>
/// MainCustomerForm
/// </summary>
public partial class MainCustomerForm : System.Windows.Window, System.Windows.Markup.IComponentConnector {

    private bool _contentLoaded;

    /// <summary>
    /// InitializeComponent
    /// </summary>
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
    public void InitializeComponent() {
        if (_contentLoaded) {
            return;
        }
        _contentLoaded = true;
        System.Uri resourceLocater = new System.Uri("/PropertyManagementPoland;component/customerforms/deletecustomerform.xaml", System.UriKind.Relative);

        #line 1 "..\..\..\CustomerForms\DeleteCustomerForm.xaml"
        System.Windows.Application.LoadComponent(this, resourceLocater);

        #line default
        #line hidden
    }

    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
    [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
    [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
    [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
    void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
        this._contentLoaded = true;
    }
}

}

我需要尽快完成我的项目,但我不知道如何解决这个问题。 问候, 巴托兹。

【问题讨论】:

  • 清理解决方案中的所有 bin 文件夹并重建解决方案。如果这不起作用,请发布您的 MainCustomerForm.cs

标签: c# wpf visual-studio-2012 compiler-errors


【解决方案1】:

我找到了解决办法!当我处理 XAML 时,我忘记在其中一种表单上更改 x:Class 名称。 谢谢你的时间,克里斯。祝你有美好的一天。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 2011-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    • 2015-07-23
    • 1970-01-01
    相关资源
    最近更新 更多