• Sliverlight常见错误集锦


    1. 使用GridSplitter时候(参考),出现如下错误

    C# 中的错误Error 2 The type 'sp:GridSplitter' was not found. Verify……

           对程序"Rebuild All",会看到最下面有一个提示:

    Error 1 The type or namespace name 'GridSplitter' does not exist in the namespace 'System.Windows.Controls' (are you missing an assembly reference?) 

           由此可知,错误的原因是没有引用“System.Windows.Controls”,右键工程“Add Reference ”,在Assemblies/Extensions/,勾选“System.Windows.Controls”即可。

    2. InvalidOperationException was unhandled by user code

    提示信息是:Operation is not valid on an active Animation or Storyboard.  Root Storyboard must be stopped first.

    意思是,该操作非法。因为一个活动的动画正在进行,不可以再绑定动画,必须先把Storyboard停止。

         该错误是在鄙人反复地绑定动画时候出错的,但是鄙人并没有在此期间对动画进行结束“leftEllipseStory.Stop()”,所以反复地“this.leftEllipseStory.SetValue(Storyboard.TargetNameProperty, "ellipseRight");”

     必然会导致资源的冲突。因为在活动状态,资源被占用,无法重新再绑定。但如果在绑定之前便停止,便可以消除该错误“leftEllipseStory.Stop();//首先停止先前的动画”。

    3. The Silverlight project you are about to debug uses web services. Calls to the web service will fail unless the Silverlight project is hosted in and launched from the same web project that contains the web service.

     解决方法:

          Make sure you set the start up project to your Web Project, not your Silverlight project. (亦即,将Web工程设置为启动项,而不是Silverlight工程)

    4. 引用不同位置的同名类所导致的错误

    Error 5 [A]MapUI.Common.LayerList.LayerList cannot be cast to [B]MapUI.Common.LayerList.LayerList. Type A originates from 'MapUI.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:UsersDowAppDataLocalMicrosoftVisualStudio11.0DesignerShadowCacheibxismzs.4wext4l5u5l.i5vMapUI.Common.dll'. Type B originates from 'MapUI.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:UsersDowAppDataLocalMicrosoftVisualStudio11.0DesignerShadowCache5okjppep.kgqqq2s0rh2.o4tMapUI.Common.dll'. D:DocumentsVisual Studio 2012ProjectsSL_RHManaslAppMainPage.xaml 55 9 slApp

     两个对象使用的不是在同一个程序集中的对象,虽然名字一样但全局命名控件不同(名称欺诈)。 

    错误说明很明显是使用了两个不同位置的同名dll

     5. 

    Error 3 Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'MapUI.Common.LayerList' that could not be found. D:DocumentsVisual Studio 2012ProjectsSL_RHManaProjectUILayersSilverlightControl.xaml 10 30 ProjectUI

    重新编译工程ProjectUI即可

    6. Silverlight程序,断点变为空心圆圈,无法调试

             打开xxx.Web的属性页,打开Web选项卡,勾选Silverlight就可以

    7. 

    Error 2 'WebGISDemo.LoginPage' does not contain a definition for 'btnLogin' and no extension method 'btnLogin' accepting a first argument of type 'WebGISDemo.LoginPage' could be found (are you missing a using directive or an assembly reference?) D:DesktopRHManaWebGISDemoLoginPage.xaml.cs 30 18 WebGISDemo

    在向工程中添加一个已有页面(Silverlight Page) LoginPage时,出现无法识别LoginPage页面的元素的问题。鄙人研究了一段时间,也没有找出问题。应该是在添加Silverlight Page,系统做了其他一些修改。

    解决方法是通过Add->New Item的方式添加,然后再通过复制代码来实现。

    The tag 'Label' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk'

    有时甚至出现此类莫名奇妙的错误,解决思路是在Blend里面打开,然后再关闭。多试几次,或许就恢复了。

     8. 图片在一个工程中能打开,在另一个工程中打不开

           未能添加入工程

    9. 用户代码未处理 NullReferenceException

       Object reference not set to an instance of an object.

      错误原因:没有对lstImageSource进行初始化

     10. length cannot be less zero. Parameter name: length ”

    Silverlight项目更改了命名空间后编译,总是在xaml文件中提示如下错误:

    “1,1,1,1,长度不能小于0,参数名length”

    “1,1,1,1,length cannot be less zero. Parameter name: length ”

    分析/解决

    托管的C#代码没有改变,原没有改变命名空间的程序编译通过,也找了一个代码相对简单的xaml,把他的后置代码全部注释掉,引用的viewmodel也全部去掉,但问题依然存在。仔细查看了一下代码,发现了一个异常的地方,比如“xmlns:XX.XX.Controls="clr-namespace: XX.XX.Controls;assembly=XX.XX " ,注意红色标记的部分,会返现原来的定义引入命名空间的名称上有异常,出现了点号。果断去掉了这个符号,程序正常了。

     11. 明明引用里已经生成,但是还是报错:错误1命名空间“clr-namespace:ProjectUICommon;assembly=ProjectUICommon”中不存在“BasicMapTool”名称

    尝试关闭解决方案然后再打开,在xaml文件中,输入ProjectUICommon,然后利用VA的提示,来输入,会比较准确。在这个过程中,如果仍然有一些错误,且这些错误无法去除,可以尝试Debug,看是否已经发生了改变。若已经发生改变,且这些错误不会影响正常使用,就不用理会。

     12. 当前不会命中断点,还没有为该文档加载任何符号

           原因比较多。有可能是DLL引用有误,也有可能是源码被VSS管理过,还未解除控制。我对这个问题感到非常头疼

    13. 最好不要将命名空间加“.”,如Project.Common

    14. Cannot implicitly convert type 'DataAccessSilverlight.PowerDataServiceReference.EntityBase[]' to 'System.Collections.ObjectModel.ObservableCollection<DataAccessSilverlight.PowerDataServiceRefe

    如上题,是Web服务的错误:

     一个是数组 一个是list 
    ObservableCollection<EntityBase> users = e.Result;
    改为:
    EntityBase[] users = e.Result;
    即可以解决问题

    15. 

    Error 45 'System.Collections.Generic.IDictionary<string,string>' does not contain a definition for 'ElementAt' and no extension method 'ElementAt' accepting a first argument of type 'System.Collections.Generic.IDictionary<string,string>' could be found (are you missing a using directive or an assembly reference?)

      加上using System.Linq即可

     16. 绑定出错:The invocation of the constructor on type 'ProjectUI.Panels.TravelPanel' that matches the specified binding constraints threw an exception. [Line: 299 Position: 97]

    经过仔细查验,是鄙人在复制类的时候,忘记给绑定属性的类别进行更改导致的,如下:

    红色部分,鄙人没有及时改为:TravelPanel,以致构造的时候出错。改过来之后,问题即可以得到解决。

     当然,也要注意到,有可能TravelPanel内的构造函数TravelPanel()内执行有误。具体,可以调制找到到错误的原因。

    17. 有不少错误都是因为某个命名空间没有引用造成的。比如,使用keyValuePair和Visibility的时候,都需要引用一些命名空间。      

    “Error 1 Member 'System.Windows.Visibility.Collapsed' cannot be accessed with an instance reference; qualify it with a type name instead ”

    这个错误的原因是没有引用“System.Windows”,所以编译器找不到Visibility这个命名空间。

  • 相关阅读:
    mybatis:"configuration" must match "(properties?,settings?,typeAliase.....
    Mybatis插件原理和PageHelper结合实战分页插件(七)
    mybatis结合redis实战二级缓存(六)
    Mybatis源码分析之Cache二级缓存原理 (五)
    Mybatis源码分析之Cache一级缓存原理(四)
    Mybatis源码分析之Mapper执行SQL过程(三)
    Mybatis源码分析之SqlSession和Excutor(二)
    Mybatis源码分析之SqlSessionFactory(一)
    spring结合mybatis实现数据库读写分离
    通过项目逐步深入了解Mybatis<四>
  • 原文地址:https://www.cnblogs.com/dowtowne/p/3304909.html
Copyright © 2020-2023  润新知