I needed to create a report in a DNN website to obtain the Total billable hours for a single case in Dynamics CRM. All my previous DotNetNuke modules for CRM had been done in VS2005, which lead me to miss a detail.
My code kept complaining about missing the Crmservice type, which after instantiation is the very same web service needed to obtain information from Dynamics CRM. After going through MSDN documentation, posting at the CRM community and searching through the web I was almost giving up.
The cause was not apparent to me because the behavior in VS 2008 was so similar to its counterpart in VS2005. The reason I kept missing it was that I did not pay enough attention to the "Add Service Reference screen.
In all my DNN modules, the Add Web Reference item in the contextual project menu is always present, but notice there’s no “Add Service Reference” item.
However in a new Console project the menu is different. The menu displays two items. “Reference” and “Add Service Reference”. Of course I went automatically to the second one and kept adding the CRM URL there. After connecting and finding the webservice, the reference was added. I did this a few times, but the CrmService error remained.
After wasting a couple of cycles searching the web, I resolved to start from scratch following the Sdk documentation step by step.
In the end, it was very, very simple. I was not adding a Web Reference. And judging from the result there is and important difference. The steps to add a Web Reference are slightly different, but only the first time in a project.
The “Add Web Reference” screen only shows up after clicking on “Advanced…” button in the first Add Service Reference screen and then “Add Web Reference…” in the Service Reference Settings screen.
A third option “Add Web reference” will appear from now on in that project.
In summary, the problem was that I had been adding a Service Reference where a Web Reference was needed.