[英]“Object reference not set to an instance of an object” error shows when adding a reference to a WCF service to a Silverlight 4 project
I have a Silverlight enabled WCF service, and a Silverlight 4 project that references it. 我有一个启用Silverlight的WCF服务,还有一个引用了它的Silverlight 4项目。
The service used to work nicely until I merged some changes another developer made into the service, since then the Silverlight project failed to call the service with "Server not found" error. 直到我将其他开发人员对服务进行的一些更改合并到该服务之前,该服务一直运行良好,因为此后Silverlight项目无法使用“找不到服务器”错误调用该服务。
I removed the reference to the service, tried to add it again but this failed with error "Object reference not set to an instance of an object". 我删除了对服务的引用,尝试再次添加它,但这失败,并显示错误“对象引用未设置为对象的实例”。
This is not limited to the above service anymore, this error happens every time I try to add any WCF service to the Silverlight project. 这不再局限于上述服务,每次我尝试将任何WCF服务添加到Silverlight项目时,都会发生此错误。
I am using Visual Studio 2010 and the .NET Framework 4.0 for all projects. 我对所有项目都使用Visual Studio 2010和.NET Framework 4.0。 This problem has happened before and I was able to solve it be creating a new solution, creating fresh projects in it and then adding the code files to the projects one by one.
这个问题以前已经发生过,我能够通过创建一个新的解决方案来解决它,在其中创建新的项目,然后将代码文件一个接一个地添加到项目中。 However, this is a nightmare now that my solution contains dozens of projects and hundreds of code files.
但是,既然我的解决方案包含数十个项目和数百个代码文件,这将是一场噩梦。
anyone out there with a fix for this? 有人为此解决吗? I googled this a dozen times and all I got was fixes to similar problems that happened with Silverlight 2 and Visual Studio 2008, but these fixes didn't work for me.
我在Google上搜索了12次,而我所得到的仅仅是针对Silverlight 2和Visual Studio 2008所发生的类似问题的修复程序,但这些修复程序对我而言不起作用。
Thanks. 谢谢。
Make sure your WCF service is working properly. 确保您的WCF服务正常运行。 Right click on the SVC file and select View in browser.
右键单击SVC文件,然后选择在浏览器中查看。 If there is a runtime problem, that should point you in the right direction.
如果存在运行时问题,那应该为您指明正确的方向。
Have you tried switching WCF tracing on? 您是否尝试过打开WCF跟踪? I find it normally provides clues to the problem source.
我发现它通常可以为问题源提供线索。 Also, have you checked your Silverlight client config?
另外,您是否检查了Silverlight客户端配置? Are the end point addresses all correct?
终点地址都正确吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.