How do I get the current Project Template Name? - c#

I have DTE.Project object - How do I get from there the Project Template Name?
I'm trying to detect the project template so I would be able to later on recreate it programmatically. if I have the name i can do it. Is that the right way to go?
I've already seen http://www.mztools.com/articles/2007/mz2007016.aspx, but not all projects have "projectTypeGuids", for example, Windows Forms Application and Console Application, and ProjectType and OutputType properties doesn't help me because they are the same for the aforementioned templates.
Thanks.

The answer could be found here: (it's hebrew)
http://blogs.microsoft.co.il/blogs/shlomo/archive/2012/10/10/how-do-i-get-the-current-project-template.aspx

Related

ASP.NET Web Application Project only shows VB options, not C#

I'm working on a project and I'm fairly new to ASP (not to C#).
We have a solution for a whole web application consisting of several projects and I want to add a couple of ASP WebForms to one of the projects. However, when I right click on the folder of the project and select Add element, it only shows me VB options.
But if I try to add other project to the solution, then all the other options are displayed.
The project in which I'm trying to add new Web Forms is entirely written in C#, so I don't know well what's happening back there. I cannot stop thinking it might a dumb mistake I'm making.
I'm working under Visual Studio 2017 and .NET Framework 4.7.2. It is there some kind of requirement I'm missing?
Thanks in advance for your time and sorry if it's something simpler, but I really don't know what's going on here.
As noted, this looks like that one application was created as a vb.net application.
You can freely consume say c# code (assemblies) in a vb.net project. And of course you can do the reverse.
However, for a given project created? You can't at the IDE level mix vb.net and c# code modules and general writing of code between c# and vb.net.
However, as in your example, you can certainly "include" multiple mixes of vb.net and c# projects into one same project. However, each part and section will still be limited to the chosen language used to build that application. So mixing is allowed at the project level - but not below that level.
So, it looks to be that project was created and developed with vb.net. You can't really change that unless you create a new project as c#, and then pull in all the forms, code etc. and re-factor the vb.net to c#.
So your practical project language choice is really limited to the project level. Multiple projects of different languages can be included overall, but each part will remain in its given language choice. The fact that you can do this in .net is amazing enough, but that language choice is really set in stone at the project level.
While you're figuring it out, if you need to press on and get some work done just copypaste another file that is already in the solution, and is of the type you require, then change its contents. This can usually be a time saver anyway, as the "new product" form isn't so hugely different from the "new user" form, just a different bunch of labels and textboxes..
There is nothing magical about the "add new item" dialog, it just adds files with pre filled templated content. For a cs class (for example) that's a file that basically has a detected namespace and the name you specified in the add dialog. You could even add a VB file of the type you want and then change the contents and name of the file to be right for C# - it would essentially be adding a couple of curly brackets and changing the case of Namespace and Class (and maybe changing Imports to using)
You cannot mix languages in the same assembly in .Net. Create another assembly you can put your C# code in there and use it in the VB.Net project.
Or use VB.Net it's not that bad.

WPF ResourceDictionary converter resource not found when startup project is a class library

As a precursor to this long winded explanation, I have looked thought the existing posts and have not found what i was looking for, I have also googles the issue and also came up with nothing that solved my issue.
I'm a self thought C# WPF noob.
This is my first post, I hate asking for help as I hate wasting other people's time. But I find myself in a situation that I have not been able to solve. So if anyone can help shed some light on this I would be greatly appreciated.
I am working on an Autodesk Revit plugin. The Solution consists of three projects,
Addin Project, is a class library that implements Autodesk Reivt IExternalApplication interface that registers with Autodesk Revit.
Manager Project , is a WPF application that is called from the Addin class library project when the user clicks a button in the Revit User Interface.
Installer, (Not relevant to this issue)
My issue is related to the resources and MergedDictionaries in the WPF application.
I have style resources for the various controls that I need to style and also data and converter resources.
I add the resources to the App.axml resources section and also to the pages in the project. The reason for that is part of my issue.
When the user clicks to open the MainWindow from the Addin Project, the resources give issues in that they cant find "x" resource. The message looks like this:
"Exception: Cannot find resource named 'FamTypeConverter'. Resource names are case sensitive."
The converter is being used in a style for ListView CellTemplate which is in another recourse file.
The strange thing is that the resource file contains other resources that work just fine. But this one in particular is giving me issues. The resource is a converter that implements IValueConverter and currently does no conversion while I troubleshoot this issue, it just returns the value for the convert and convert back methods.
I have another converter in the same *.CS file called "FileSizeConverter" that simply converts an INT input into a formatted file size string. The Resources is in the same dictionary and points to it's converter in the same *.CS file, different class (obviously), witch one works perfectly.
I have tried using static and dynamic recourses, setting the build action of the resource xaml files to page, resource, Embedded Resource with no change in results.
I have tried adding the resource to the pages them-selves and tried relative and Pack url's. nothing seems to work. I also have to add the MergedDictionaries to the main window, pages and the app.xaml for the resources that do currently work, to work. if I don't add the resources to the pages I get the same error, cannot find "x" resource.
If I set the start up project to the WPF project, then there is no issue. All resources work.
I think the issue is that the starting project does not load or cache the resources in the WPF project when the Window is in another project.
I'm 80% sure this is related to the fact that the WPF application extends "Application" and the class library does not! I presume the application class is where the resources are loaded but this is where my lack of knowledge kicks in.
I have no clue if I am on the right track or if I have missed something so obvious that I will want to kick myself when I realize what is wrong.
Sorry for the long winded explanation, and I hope that I have made myself clear and concise. If any clarity is required please feel free to request.
Thankyou in advance
Dereck Clements
I ended up moving any GridView styles to the page rather than a resource dictionary. I Think it was related to the converter being used in the resource dictionary that caused the issue to begin with. Having the GridView defined on the page solves the problem.

Re using wpf window and c# in base project for using again

I am still getting used to working with c# and wpf. I have made a number of smalls apps to do single tasks. To give the same feel to the apps my company uses I use the same logo, colours and layout.I am also developing a project settings class to save the project variables to file using a json file ( I hope ) and a slide out panel to give the user access to the project variables.
It would make sense to save this as a sort of template / base project so that every time I start a new project I can use this base project to shortcut the workload but every time I to do this I get errors. I have read about class library but am not certain if the is correct way forward or should be some sort of template.
Can someone explain if want I want to do is possible in wpf and what is the correct way forward please. Any questions on here (this site) assumed a bit too much knowledge for me and I can't get my head around the msdn references. So any good links would be helpful
Thanks
In Visual Studio, once you have the basic solution template that you want.
File->Export Tenplate.
Create a new Project Template.
Or if you just want to create a reusable theme. Create a class library and put some ResourceDictionaries inside with your styles and templates, etc. Then reference it from each new project and import the resource dictionaries. This solution would probably be easier to maintain over time as you could easily replace the referenced DLL with a new version when you make changes to the common UI theming.

There is no Default.aspx.cs file into my webapplications project

Before telling you anything i'd like to clear, I'm a completely beginner in ASP.NET. In fact, I started learning today ASP.NET.
So, I'm making an event that would bind my code with C# files. Well I'm good in C#.
But the problem is as I find into projects, there is no Default or any aspx.cs files here. Can you please help? Where can I find it?
This tutorial says that to bind events, you need to write code in .cs files.
Here is my how my project is setup:
I think you have choosen a wrong project type while creating your project.For your purpose you need to do following
File>New>Project
On the left panel Go Visual C# > Web
Select ASP.NET Web Forms Application
Looking at your screenshot it seems you selected "ASP.NET Empty Web Application".You can add files to this as well but since you are a beginner its better to follow above steps.

Where do I find MVC4 templates for download and how do I install them?

I am somewhat confused. Searched a bunch of ASP.NET related sites but could not find the answer. I must be missing some search word..
I want to find a gallery of MVC4 templates (free/cheap) and apply them to my project. Where do I do that from? I found one codeplex project (http://mvccontribgallery.codeplex.com/), but when I tried applying by copying, there were a bunch of errors (it uses something called SiteMaster, while my project seems to be using something called _layout).
I see a ton of references to people using them, applying them, but I must be missing something very fundamental since I can't even figure out how to find a list of downloadable templates.
What are the simple 1/2/3 steps for finding/getting/installing a template on my MVC4 project?
You should be looking for a suitable HTML template instead of an MVC specific template.
Once you have that, you will need to modify you master template (usually Views/Shared/_layout) to use the HTML and CSS contained within the template you have chosen.
For MVC3 or MVC4 you don't need to download any template. Just install MVC4 in your visual studio 2010 version on higher and then choose option create new project and that is that. See this below screen capture:
Microsoft will provide you the default MVC project architecture or in your term MVC template automatically when you choose any of above option marked in red box.
What do you mean by mvc4 templates? I'm assuming you mean "website template". With MVC you can use any html template, there's no specific template for MVC (that's why you're not finding any of it). You just find any website template and adapt it to mvc context (put css and images under "Content" folder and put html code in _layout and use it like masterpage), not hard to do at all. In fact, so easy to do after you get the idea that no one publish a specific adapted version :)
Follow these steps:
(note: if you have Asp.Net MVC 4, 3 won't install right (for me anyway), so uninstall and install in order).
http://tedgustaf.com/blog/2011/4/installing-asp-net-mvc3-on-visual-studio-2010-sp1/

Categories

Resources