错误 BC30663 属性“CompilerGenerateAttribute”和“DebuggerNonUserCodeAttribute”无法在 VB.NET 中多次应用

问题描述 投票:0回答:1

从 C# 转换为 VB.NET 后出现错误。

Error BC30663 Attribute 'CompilerGeneratedAttribute' & 'DebuggerNonUserCodeAttribute' cannot be applied multiple times
但是在C#中运行就没有报错的问题了,

请指导我

谢谢

Vb.net 中的代码

Namespace My.Resources

    <GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")>
    <DebuggerNonUserCode>
    <CompilerGenerated, _
    Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
    Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
    Global.Microsoft.VisualBasic.HideModuleNameAttribute()>
    Friend Module Resources

        <EditorBrowsable(EditorBrowsableState.Advanced)>
        Friend ReadOnly Property ResourceManager() As ResourceManager
            Get
                If Resources.resourceMan Is Nothing Then
                    Resources.resourceMan = New ResourceManager("Resources", GetType(Resources).Assembly)
                End If
                Return Resources.resourceMan
            End Get
        End Property

        <EditorBrowsable(EditorBrowsableState.Advanced)>
        Friend Property Culture() As CultureInfo
            Get
                Return Resources.resourceCulture
            End Get
            Set(ByVal value As CultureInfo)
                Resources.resourceCulture = value
            End Set
        End Property


        Private resourceMan As ResourceManager

        Private resourceCulture As CultureInfo
    End Module
End Namespace

以下 C# 代码

namespace Utils.Properties
{
    [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
    [DebuggerNonUserCode]
    [CompilerGenerated]
    internal class Resources
    {
        
        internal Resources()
        {
        }

    
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        internal static ResourceManager ResourceManager
        {
            get
            {
                if (Resources.resourceMan == null)
                {
                    Resources.resourceMan = new ResourceManager("Utils.Properties.Resources", typeof(Resources).Assembly);
                }
                return Resources.resourceMan;
            }
        }

        
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        internal static CultureInfo Culture
        {
            get
            {
                return Resources.resourceCulture;
            }
            set
            {
                Resources.resourceCulture = value;
            }
        }

    
        private static ResourceManager resourceMan;

        
        private static CultureInfo resourceCulture;
    }
}
c# vb.net winforms resources
1个回答
0
投票

感谢@Craig的建议,问题终于解决了

Namespace Utils.Properties

    <GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")>
    <DebuggerNonUserCode>
    <CompilerGenerated>
    Friend Class Resources
        
        Friend Sub New()
        End Sub

    
        <EditorBrowsable(EditorBrowsableState.Advanced)>
        Friend Shared ReadOnly Property ResourceManager As ResourceManager
            Get
                If Resources.resourceMan Is Nothing Then
                    Resources.resourceMan = New ResourceManager("My.Resources", GetType(Resources).Assembly)
                End If
                Return Resources.resourceMan
            End Get
        End Property

        
        <EditorBrowsable(EditorBrowsableState.Advanced)>
        Friend Shared Property Culture As CultureInfo
            Get
                Return Resources.resourceCulture
            End Get
            Set(ByVal value As CultureInfo)
                Resources.resourceCulture = value
            End Set
        End Property

        
        Private Shared resourceMan As ResourceManager

        Private Shared resourceCulture As CultureInfo
    End Class
End Namespace

© www.soinside.com 2019 - 2024. All rights reserved.