当我想将自定义控件程序集 (DLL) 文件添加到 Visual Studio 工具箱时,遇到以下错误:
从程序集“我的程序集文件”加载类型时出错。
类型违反了继承安全规则:ItemsCollectionEditor。派生类型必须要么与基类型的安全可访问性相匹配,要么难以访问。
此外,我将程序集 SecurityRulesAttribute 添加到 AssemblyInfo.cs 文件以解决问题。但是,它对我不起作用。
我的 AssemblyInfo 文件代码是:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
[assembly: AssemblyTitle("WindowsFormsControlLibrary2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("SSSSSSSSS")]
[assembly: AssemblyProduct("WindowsFormsControlLibrary2")]
[assembly: AssemblyCopyright("Copyright © SSSSSSSSS 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("ed5d434c-36e8-4883-a4d3-3eb6459546b3")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyKeyFile("Saino.snk")]
[assembly: AssemblyKeyName("")]
[assembly: System.Security.AllowPartiallyTrustedCallers]
[assembly: SecurityRules(SecurityRuleSet.Level2, SkipVerificationInFullTrust = true)]