I cant add a class to a Visual Studio UML Architecture Model.
When I drag/drop a class from the Solution Explorer onto the UML model the mouse cursor changes to a "cant drop" icon.
Also in Architecture Explorer its not showing any types or namespaces:
The class definitely has a namespace and types, its a been generated from a wsdl file. I've tried other classes like the ColourObject.cs (full of types) and encounter the same problem.
Video's I've seen show people just dragging classes onto the model and abra-cad-abra.
What am I missing?
Ok I see my mistake, I could built the project fine.
Though when I added vanilla class to the UML model (from the UMLModel Explorer) and generated, then a Lib Project was created. I added my wsdl Proxy Class file to the Lib Project and tried to built and it failed.
It failed due to some missing references like System.Web and System.Web.Services after adding them the project built fine and then Architecture Explorer showed me all the Types and I was able drag/drop them onto the Model.
Related
I had a solution that contained two projects, one for the web layer that also contained the models, and another for a Windows forms project that did some other "stuff". The forms project referenced the web project, and all was fine up until I needed to reference something from the web project in the forms project, which I could not do for circular reference reasons.
So I created a new solution, put the data layer in one project and the web layer in another, so later on I could add the third project, and put in the references I need. Now when I run the web project, I get the following error;
So I understand that the web project is struggling to find my namespace from the data project, but I have referenced it, so I don't know what more to do.
***EDIT
This comes as no shock, but it's the view that's the issue. If I edit my Index.cshtml, it recognises the referenced project. I tried adding;
#using LottoData.Models
and intellisense completed as I typed. However, when I run it now, I get;
Help!
This was my bad. I forgot to change the output type for the data project to "Class Library", it was still set to "Console Program". Changed that, removed and re-added the reference, cleaned and rebuilt and it works fine now. Thanks #David and #Armand for your input.
I have a C# class library project in Visual Studio 2017 that I would like to create a class diagram for. The Class Designer is installed. Looking at the context menu for the namespace or any of the classes in the Class View I see the "View Class Diagram" option and also the button for same on the view's menu bar.
However, when I click either the button or the context menu item nothing seems to happen! Flipping back to the Solution Explorer view I can see a ClassDiagram1.cd file has been added to the project. Attempting to open this file though results in an error message:
Class diagrams are not supported by this project type.
Add the class diagram file to a C#, VB or C++ project and try opening it again.
I'd be happy enough to be able to add a diagram myself rather than have it generated if generation is not possible. But I also cannot add a blank class diagram file to the project as that file type does not appear in the file types list in the Add New Item form.
How can I create a class diagram for classes contained in a class library? Or maybe class diagrams are not available for libraries? If the latter is the case is there any info from Microsoft to A) confirm this and B) explain why classes in a program can be diagrammed but not classes in a library. (I did already spend some time googling this matter but did not find anything specific to class libraries)
Since this is the Google #1 link for problems with the Class Designer and surprisingly nobody cared to answer so far (especially the part "Class diagrams are not supported by this project type"), let me chime in:
Close VS and open the file at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.CSharp.DesignTime.targets
Search for the line
<ProjectCapability Include="CSharp;Managed"/>
Write "ClassDesigner" as a capability like this:
<ProjectCapability Include="CSharp;Managed;ClassDesigner"/>
Save the file and re-open VS. Your class diagram should work now. You should even be able to add new ones (at least I can in my .NET Standard 2.0 Class Library project in VS2017.5.3).
Actually, the correct answer is to use the Visual Studio Installer as described here in the Microsoft Documentation. And it works!
how-to-add-class-diagrams-to-projects
As far as I can tell, Class Diagrams are not currently supported in .Net Standard and .Net Core projects (they share the same project type) in VS 2017. There are several threads about this on Developer Community, which didn't receive much of a response from Microsoft so far.
You might want to consider creating an issue about this on the dotnet/standard repo.
In Visual Studio 2015, the view option is missing class diagram as represented in the following image.
I have tried Enterprise Architect but that software is unable to detect C# 6 syntax. For example whenever there's public static String readonlyText => "123";, it skips the class.
What's the solution to generate class diagram based on ASP.Net Core code?
In Class View (Ctrl+Shift+C) Right click a namespace or class, and you should see the 'View Class Diagram' option. Useless tho, nothing happens when you click it.
This was probably not working in previous versions, Now in 'Class View' (Ctrl-Shift-C), right click a namespace or class, then click 'View Class Diagram' which creates a new class diagram in the root folder of your project.
Contextual menu in the 'Class View pane'
This works at least in the last edition of VS community edition:
Version in which the feature is working
The new class diagram file, starts empty though.
Running VSPro 2013 on a x64 Win7 machine, creating a C# Console Application called PROJ, using .NET4 and using a class library I build IN THE SAME PROJECT. Class lib is called CHILD1 in CHILD1NAMESPACE. In PROJ, I have using CHILD1NAMESPACE; and it works!
I then created CHILD2, in CHILD2NAMESPACE... IN THE SAME PROJECT... with the exact same settings as CHILD1 (.NET4 / Class Library).
using CHILD2NAMESPACE; gives me an error! The Type or namespace CHILD2NAMESPACE could not be found...
I've searched the web and most resolutions include switching frameworks because the class library and parent are using different frameworks. In my case, they are all using .NET4 (not client) and are within the same Project. I've restarted VS several time... cleaned, re-built etc.
Any clues would be appreciated.
Thanks
-Ed
It looks like you created two projects (csproj) inside one solution.
In order to make one project access the other one you must add a reference between the projects.
In orde to do that, right click over the the project that is not building and click on "Add reference" you can choose the solution and select the project being referenciated.
I am using Windows Workflow Foundation with custom Activities, and I would like to create custom Design for these activities in my workflow.
I am able to make the design project, and the designer xaml. Also I am able to see the custom design for them in the workflow, if I directly refer the Design project in my Workflow project.
This is something that I would not like to do, because the Designer DLL should not be deployed to production environment. I would only like to have the custom design in Visual Studio workflow editor.
I was able to get things working by adding following:
[Designer("namespace,dll")]
public class CustomActivity : NativeActivity<string>
and after this copying the dll to visual studio path. This is again something that I would not like to do, because every developer should do this and making the build so that the dll is copied some fixed visual studio path is not very good.
I used these two examples, but it seems that both of these directly refer the DLL:
http://geekswithblogs.net/jkurtz/archive/2010/01/26/137639.aspx
http://code.msdn.microsoft.com/Windows-Workflow-9e867448
I would assume this kind of feature would somehow be supported by the Visual Studio/Workflow Foundation.
Do you have any ideas how to resolve this? Thanks!
The Designer attribute (using "magic" string) is not something very reliable. If you change your class name or namespace, you'll not have a compilation error.
There is another (better imho) way to do it using IRegisterMetadata implementation:
Your Design assembly must reference your activity assembly, but this usually can't be avoided.
Add a partial class (.cs) to your XAML designer
This class must inherit from System.Activities.Presentation.Metadata.IRegisterMetadata. this interface only define one method to implement.
Here is a implementation sample:
public void Register()
{
AttributeTableBuilder builder = new AttributeTableBuilder();
builder.AddCustomAttributes(
typeof(MyActivity),
new DesignerAttribute(typeof(MyActivityDesigner)));
MetadataStore.AddAttributeTable(builder.CreateTable());
}
Next, you'll want to have the custom designer used in Visual Studio. Visual Studio have strict rules to automatically load designer assemblies. You need:
Your designer project must have the same name than your activity project, with ".Design" added at the end. Example:
Activiy project: MyApp.Activities.dll
Designer project: MyApp.Activities.Design.dll
The .Design dll must be in the same directory than the activity dll. You can automate this with a post build event in the designer project.
Important Edit:
I see now that your links already present this method but you say that it directly reference the DLL. Yes, the DESIGN dll reference the ACTIVITY dll.
But you asked the opposite: the activity dll shouldn't reference the design dll.
Using the IRegisterMetadata method, your DESIGN dll can reference the ACTIVITY dll, it's not a problem: you can remove the design dll from the released package, the activity dll will work fine.