值不在预期范围内。

25

尝试显示表单设计师时出现错误。

查看错误图片:

enter image description here

屏幕代码:

public partial class frmCanalVenda : frmEdit
{
    public frmCanalVenda(CanalVenda canal, Cliente cli)
        : base(canal)
    {
        InitializeComponent();
        bdsCliente.DataSource = cli;
        eabBar.ReadOnlyView = false;
    }

    private void frmCanalVenda_Load(object sender, EventArgs e)
    {
        try
        {
            Cursor.Current = Cursors.WaitCursor;

            bdsAgrupamento.DataSource = Agrupamento.GetAll(DatabaseAFV.Connection);
            bdsCanal.DataSource = Canal.GetAll(DatabaseAFV.Connection);
            bdsSubCanal.DataSource = SubCanal.GetAll(DatabaseAFV.Connection);
            bdsEspecializacao.DataSource = Especializacao.GetAll(DatabaseAFV.Connection);
            bdsOperacao.DataSource = Operacao.GetAll(DatabaseAFV.Connection);
            bdsPorte.DataSource = Porte.GetAll(DatabaseAFV.Connection);
        }
        finally
        {
            Cursor.Current = Cursors.Default;
        }
    }
}

图像文本

在加载设计器之前,必须解决以下错误以防止可能的数据丢失:

值不在预期范围内。

此错误的实例(1)

  1. 隐藏呼叫堆栈 在System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)处引发异常,在Microsoft.VisualStudio.NativeMethods.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure)处引发异常,在Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetFileDocData(String fileName, FileAccess access, String createTemplate, Boolean addToHostList, Boolean nestedItem)处引发异常,在Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetChildDocData(String name, FileAccess access, String createTemplate)处引发异常,在Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.GetResourceDocData(CultureInfo info, FileAccess access)处引发异常,在Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.System.ComponentModel.Design.IResourceService.GetResourceReader(CultureInfo info)处引发异常,在System.ComponentModel.Design.Serialization.ResourceCodeDomSerializer.SerializationResourceManager.GetMetadata()处引发异常,以及在System.ComponentModel.Design.Serialization.ResourceCodeDomSerializer.SerializationResourceManager.GetMetadataEnumerator()处引发异常。在System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertiesFromResources(IDesignerSerializationManager manager, Object value, Attribute[] filter)处反序列化属性,然后在System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)处反序列化类型声明。在Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)和System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)中执行加载。

为什么不发布错误的文本?图片显示不清楚。 - Oded
@Oded:如果你放大页面,它就变得可读了:p - Kornelije Petak
@Kornelije Petak - 如果你想复制/粘贴,你仍然无法做到。 - Oded
3个回答

50

一个绝望的尝试:重新启动Visual Studio对我有用。


3
哈哈,这差不多就像“重新启动”或“重装Windows”一样。不过它起作用了,我点了个赞 :) - Nilzor

3

这个问题可能是由于项目属性/设置文件的更改引起的。如果最近有对设置进行更改,请执行以下操作:

  1. 检查设置的xml文件中是否包含任何不必要的元素。
  2. 关闭Visual Studio,重新启动VS并打开项目。

这样应该可以解决您的问题。


我们的小伙子,这是六个月前的事了,我甚至都不记得我当时是怎么解决它的了。 - ridermansb
我使用 Git,我检出了旧的提交记录,但它没有起作用。 - Ramil Aliyev 007

0

对我来说,卸载项目并重新加载项目是有效的。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接