Monday, February 28, 2011
Service Factory Error DSL5012 / DSL5017
“Error 1 [ModelBus]: DSL5012: Exception occurred attempting to create an adapter.\nAdapterManager: Microsoft.Practices.ServiceFactory.
DataContracts.ModelBusAdapters.Data ContractDslAdapterManager\nAssembly : Microsoft.Practices.ServiceFactory. DataContracts.ModelBusAdapters, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35\nEx ception: ModelingAdapterReferenceFormatExcep tion\nException message: DSL5017: The full path representing a Model file is null or empty or invalid. Please specify a valid accessible file location for this Model.”
If you have ever received this error, you know the pain I have once felt. This is use of the ServiceFactory found at CodePlex and had literally no helpful information to get this solved. Now, it is actually a very simple problem to fix and after almost a full lost day of work and, additionally, new changes to TFS (Team Foundation Server), we have a solution.
The core issue is that the “data contracts”, the objects that your service contract is referencing has, in fact, a bad reference. That reference needs to be fixed. I am going to setup a mock example to help walk you through this problem.
1) Locate the service contract file that is giving you the above error. In the image below, you can see my project, title ASAPModel. The servicecontract that is giving me the error is called: SO.servicecontract. Double-click the file and it should open up the graphical diagram.
2) Take notice, in my example above, that I have 2 types of data contracts. One is “Employee.datacontract” and the other is “SO.datacontract”.
3) Once the SO.servicecontract file opens up it should looke like something similar to this:
4) Find a data contract object. For this example, the type “ProjectCode”, which is highlighted in blue in the above example, is of type SO.ProjectCodeDC, which is a data contract object from the SO.datacontract file. When you click on it, in the properties window, on the right, you will see several properties related to this object. Find the “Type” property, click in the field and click the “…” button on the right. That will bring up the box you see below:
5) Notice the big red “X” and the sentence next to it. Ok, so just click the ‘Browse’ button and the “Open Dialog Window” will pop up:
6) Select the corresponding data contract file, so for our example, ProjectCodeDC is from the SO.datacontract file under the ASAPModel project, click on the file and click ‘OK’. Which will bring us back to the first screen with a very good sign, all of our data contracts!
7) From here, open the DataContracts node and find your data contract, which in our case is ProjectCodeDC. Click on it and click ‘OK’, next a window will pop up only if you have multiple references to the datacontract file that were bad, as below:
8) Click ‘Yes’ here and that will reset the references to the data contract file. Repeat this for an object for each DIFFERENT data contract. So in my example here, I would have to find another object, inside the SO.servicecontract graphical diagram that referenced the Employee.datacontract file, and follow the same steps.
9) Once you are all done, reload the projects and then simply right click and generate, from inside the service contract file that was causing the error and VOILA!
10) To be fair, I did not figure this solution out, my boss did, however, I understand the issue and how it is resolved, so that is why I am writing this little article up. Hopefully, nobody will have to deal with this issue again!