Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用操作C#和Silverlight_C#_Silverlight - Fatal编程技术网

调用操作C#和Silverlight

调用操作C#和Silverlight,c#,silverlight,C#,Silverlight,有人能帮我写下面的代码吗 我正试图通过RIA Silverlight将值从服务器传递到客户端,但一直得到NullReferenceException 我已经删除了我尝试过的所有其他尝试,并且刚刚发布了最后一次尝试 服务器端代码 在没有看到异常的堆栈跟踪的情况下,我不得不猜测 可能性1 可能是ObjectContext为null,因此,此行将抛出您得到的异常 return (from p in this.ObjectContext.at_AdvertVideoAdvertisement

有人能帮我写下面的代码吗

我正试图通过RIA Silverlight将值从服务器传递到客户端,但一直得到
NullReferenceException

我已经删除了我尝试过的所有其他尝试,并且刚刚发布了最后一次尝试

服务器端代码
在没有看到异常的堆栈跟踪的情况下,我不得不猜测

可能性1 可能是
ObjectContext
null
,因此,此行将抛出您得到的异常

return (from p in this.ObjectContext.at_AdvertVideoAdvertisement 
        where p.AdvertMediaMonthYear == strMonthYear 
        select p.AdvertMediaURL).ToList();
可能性2
this.ObjectContext.at_advertVideoAdvertision
的内容是否有可能为
null

如果是这样,
p
可能是
null
,这将导致查询抛出异常

可能性3 我怀疑冒犯的界线是:

iv.Value.ToString();
这一行什么都不做,但是您也会在一个有用的上下文中重复几行,所以第一个声明可能是错误的。但是,这假定由
VideoAdvertedDomainContext.GetMediaURLBasedOnMonthYear
返回的
InvokeOperation
值不是
null
,并且其
属性不是
null
。情况可能并非如此

推荐
我建议在这些行上放置一个断点,并在调试器中查看变量的外观,以跟踪
null
引用。从那里,你可以开始找出为什么它是空的,或者让它不是空的,或者修复代码,使其能够正确处理
null
引用。

告诉我们哪个对象为null如何?请发布异常的堆栈跟踪。异常详细信息:System.NullReferenceException未由用户代码处理消息=对象引用未设置为对象的实例。StackTrace:在MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex,Delegate handlerDelegate,Object sender,Object args)的MS.Internal.JoltHelper.FireEvent中加载了Web.Silverlight.MainPage.MainPage(对象发送者,RoutedEventArgs e)的Web.Silverlight.MainPage.MainPage(IntPtr unmanagedObj、IntPtr unmanagedObjArgs、Int32 argsTypeIndex、Int32 actualgstypeIndex、String eventName、UInt32标志)InnerException:服务器端代码在命中断点时返回数据。只是没有按照null引用异常通过RIA将数据传递给silverlight
return (from p in this.ObjectContext.at_AdvertVideoAdvertisement 
        where p.AdvertMediaMonthYear == strMonthYear 
        select p.AdvertMediaURL).ToList();
iv.Value.ToString();