views:

14

answers:

1

Hi,

I have a question concerning the class generation in Visual Studio 2008.

I use a web service which is added using Add Web Reference. It works great and all the classes seem to have been generated successfully. When I try to generate a class diagram using View Class Diagram for the project which uses the web service, I get:

Some of the selected type(s) cannot be added to the class diagram. Check the code for errors and ensure that all required assemblies are referenced

I have followed both of these suggestions, and the project has no errors or warnings. I get no error for other projects in the same solution which do not use any web service.

The web service http://foo.bar.com/wsdl/ in a bit anonymized form (though it still has the same structure, I just changed some names) can be found here if it is important for the answer: http://pastebin.com/rd7W9BA6

Append

  1. As an example if I double left-click on class Age inside the WebService folder (in the tree) in Class View I get to see the public partial class Age in the file Reference.cs.
  2. I can see the above Age class in Object browser as well.

It really seems like I have all the necessary information to build a class diagram. But when I right click on said class and choose View Class Diagram I get the error message quoted above.

If I right click any other class, which is not in the WebService folder, and choose View Class Diagram I get to see the diagram for the clicked class. So it must have something to do with it being generated from a WSDL-file.

A: 

Right click the project and choose Add Existing Item. Add the Reference.cs file to the project.

Now View Class Diagram for the entire project works as the Reference.cs-file may be accessed by the class diagram generator.

The downside is that you have a generated file as part of your project. And that it won't stay up to date as it is being copied when added. Thus this solution is really only to be used when in need of a class diagram, and then the added (copied) Reference.cs should be deleted as you will step in to conflicts if you don't. When you delete it, those classes are marked as unavailable in the class diagram. So export it as a picture first.

Binary255