Apr 21

Object reference not set to an instance of an object when start debugging in Visual Studio

I’m building a c# solution with two projects

  • Windows Phone 7.1 (Silverlight)
  • Scheduled Task Agent (c#)

When I start debugging (F5) in Visual Studio 2010 I get the message:

“Object reference not set to an instance of an object”

The solution start and there seems to be nothing wrong with the app. Everything works fine, in spite of the error. Because this is very annoying, I deceided to solve this issue.

What was wrong: I’ve set Multiple Startup Projects on the properties of the solution. The Phone project should be started as well as the Scheduled Task Agent. The last setting is the problem. There is no need to set the Schedule Task Agent to start, since it is referenced by the Windows Phone project (On the WP7 project -> add reference -> Project) and will startup when the WP7 project needs this reference.

The solution: Remote the ScheduledTaskAgent from the Multiple Startup Projects list.

Simple once you know it . . . . . .

CD

 

Apr 20

Windows Phone App starts and closes immediatly in Visual Studio after renaming app / namespace

Hi Guys,

I’ll take you to a shortcut: from 10 hours to 10 seconds: After programming my app, and renaming the namespace and the project my app on my Windows Phone Emulator start and then closes againg. No error, no debugging possible.

As many time this 10 hours search for the solution (than only took 1 hours of programming) I found the solution:

  • Go to the properties of your project (not your solution)
  • Open the Application tab
  • Set the correct startup object (in my case this was empty)

Do to the renaming of my namespace / app this startup object was empty, so there was no object to start the app with.

Microsoft: a simple warning if no startup object was found should be nice.

CD

Apr 08

WCF Service Reference not found when using WCFtest.exe or add service reference

My issue is as follows when I wrote a Windows Communications Foundation Service:

    • Datacontract + datamembers
    • Servicecontract + Operationscontracts
    • manual written the web.config file

Unfortunately Visual Studio didn’t find any webservice when trying to add the service reference to a project.

The root cause: I’ve written the serviceimplementation in a class (.cs file), in stead of a WCF Service

The solution:

  • add new item to the project (WCF Service)
  • copy the service implementation from the .cs file to the WCF service file (.svc)

Easy as 1-2-3.

CD