0

在项目中的每个表单设计器上都出现此错误。我刚刚添加了 RegistrySettingsProvider.cs,这开始发生了。应用程序工作得很好,没有任何错误、警告。

问题很奇怪。当我进行更改时它没有发生,但是当我重新启动 Visual Studio 2012 时它开始出现。

找到了类似的线程http://social.msdn.microsoft.com/Forums/en-US/vbide/thread/f72f7629-19e3-4ce8-bff7-64a08b114b26/ 但没有解决方案。

at Microsoft.VisualStudio.Design.VSTypeResolutionService.System.ComponentModel.Design.ITypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.System.ComponentModel.Design.ITypeResolutionService.GetType(String name, Boolean throwOnError)
at Microsoft.VisualStudio.Shell.Design.VirtualTypeBuilder.ExecuteExpression(Resolver resolver, CodeExpression expression)
at Microsoft.VisualStudio.Shell.Design.VirtualTypeBuilder.FillAttributes(Resolver resolver, CodeTypeMember member, Attribute[]& customAttributes, MemberAttributes& memberAttributes)
at Microsoft.VisualStudio.Shell.Design.VirtualTypeBuilder.InitializeFromType(ITypeResolutionService typeResolutionService, CodeTypeDeclaration typeDecl, String namespaceName)
at Microsoft.VisualStudio.Shell.Design.VirtualTypeBuilder.InitializeFromType(ITypeResolutionService typeResolutionService, CodeNamespace ns)
at Microsoft.VisualStudio.Editors.SettingsGlobalObjects.SettingsFileGlobalObject.BuildType()
at Microsoft.VisualStudio.Editors.SettingsGlobalObjects.SettingsFileGlobalObject.GetObjectType()
at Microsoft.VisualStudio.Shell.Design.GlobalType.get_ObjectType()
at Microsoft.VisualStudio.Shell.Design.GlobalObject.GetHashCode()
at System.Collections.Generic.ObjectEqualityComparer`1.GetHashCode(T obj)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.VisualStudio.Shell.Design.GlobalObjectService.TrackGlobal(GlobalObjectProvider p, GlobalType g)
at Microsoft.VisualStudio.Shell.Design.GlobalObjectService.GetGlobalObjects(Type baseType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetTypeFromGlobalObjects(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String typeName)
at Microsoft.VisualStudio.Design.VSDesignSurface.EnsureExtensions(IComponent component)
at Microsoft.VisualStudio.Design.VSDesignSurface.CreateInstance(Type type)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload) 
4

1 回答 1

2

通过在主窗体中的 IntializeComponent 方法之后在运行时设置提供程序解决了我的问题。

public FormMain()
{
    InitializeComponent();
    var registrySettingsProvider = new RegistrySettingsProvider();
    Settings.Default.Providers.Add(registrySettingsProvider);
    foreach (SettingsProperty property in Settings.Default.Properties)
    {
        property.Provider = registrySettingsProvider;
    }
}

并确保覆盖 Settings Provider 中的 Name 属性。

public override string Name
{
    get { return "RegistrySettingsProvider"; }
} 
于 2012-09-05T11:54:55.163 回答