Application.Designer.cs错误 - 无法找到程序集属性

时间:2014-11-18 20:37:12

标签: c# vb.net properties namespaces assemblies

我正在帮助将Visual Basic项目转换为C#。以下是Application.Designer.cs文档中的原始VB代码:

'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.34014
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On


Namespace My

    'NOTE: This file is auto-generated; do not modify it directly.  To make changes,
    ' or if you encounter build errors in this file, go to the Project Designer
    ' (go to Project Properties or double-click the My Project node in
    ' Solution Explorer), and make changes on the Application tab.
    '
    Partial Friend Class MyApplication

        <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
        Public Sub New()   
            MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
            Me.IsSingleInstance = False
            Me.EnableVisualStyles = True
            Me.SaveMySettingsOnExit = True
            Me.ShutdownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
        End Sub

        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.ePlanSysOman.frmMain
        End Sub
    End Class
End Namespace

以下是从在线VB到C#转换器的结果的代码:

using Microsoft.VisualBasic;
using Microsoft.VisualBasic.ApplicationServices;//I added this in
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;//I added this in

namespace My
{

//NOTE: This file is auto-generated; do not modify it directly.  To make changes,
// or if you encounter build errors in this file, go to the Project Designer
// (go to Project Properties or double-click the My Project node in
// Solution Explorer), and make changes on the Application tab.
//
    internal partial class MyApplication
    {

        [System.Diagnostics.DebuggerStepThroughAttribute()]
        public MyApplication() :     base(global::Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
        {
            this.IsSingleInstance = false;
            this.EnableVisualStyles = true;
            this.SaveMySettingsOnExit = true;
            this.ShutdownStyle = global::Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses;        
        }

        [System.Diagnostics.DebuggerStepThroughAttribute()]
        protected virtual void OnCreateMainForm()//I changed "override" to "virtual" 
        {
            this.MainForm = global::ePlanSysOman.frmMain;
        }
    }
}

未找到的属性如下:

this.IsSingleInstance
this.EnableVisualStyles
this.SaveMySettingsOnExit
this.ShutdownStyle
this.MainForm

我查看了每个人,并为他们准备了正确的命名空间和程序集。我遇到的另外两个问题是:

base(global::Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
//I receive the following error: "object' does not contain a constructor that takes 1 arguments

global::ePlanSysOman.frmMain
//I receive the following error: 'ePlanSysOman.frmMain' is a 'type', which is not valid in the given context

VB代码没有错误。只有C#代码包含错误。我对这两种语言都不太熟悉,我们非常感谢任何有助于解决这些错误的建议。

1 个答案:

答案 0 :(得分:1)

对于VB应用程序,有一个&#34;应用程序框架&#34;默认启用并从项目 - &gt;访问属性 - &gt;应用

enter image description here

你的所有事情&#34; Not Found&#34; list是该FrameWork的一部分,MainForm除外。而不是像在C#中那样将program.cs添加到项目中以显示表单,VB创建主表单的实例并从设计器代码中显示它。