How can I tell Visual Studio I have code not in App_Code folder? - visual-studio

We've been using Visual Studio 2005 Team Suite for a fairly large web project. Now, we're adding another web app into our current project...it is essentially complete, and we're just adding the entire thing as a folder into our current project. The project builds, runs...everything is fine...but this new sub-project doesn't have any kind of Intellisense that recognizes the classes we've created for this sub-project.
I think that this is probably because the code for the project isn't in the App_Code folder, and so Visual Studio doesn't know where to find it. Does that make sense? If so, what can I do about it?

As fas as I know, that's just the way it is. For some reason, the default template for web apps in 2005 does it like this. If you just need small stuff, making the classes not in App_Code implement an interface, and then just use this when you interact with your code that reside somewhere outside of App_Code (for whatever reasons).
Otherwise, you can choose to use a different project model (doesn't ship with 2005, so need to be installed seperatly, and conversion could be non-trivial):
http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx

Related

In a TFS project, Visual Studio marks WCF classes as “Type or namespace could not be found”, but can compile and build them perfectly

I have a solution file created with Visual Studio 2013. In it, I have a WCF project which contains some classes, and a Web Application project that calls some functions from WCF file. The web Application is able to reach it from codebehind of .aspx pages.
I have no issue building and compiling the WCF project. However, Visual Studio is unable to identify their classes.
In Web Application project, It underlines the using statement of the WCF class library in red, shows "Type or namespace could not be found" error. It takes the class from the file created by WCF automatically by Visual Studio.
WCF project is doing the same inside too. The two classes are in the same namespace, in fact, literally in same file together. Yet they can't see each other.
Long story short: I have 2 different projects in the same solution, they work and compile very well, but Visual Studio is unable to identify some of the classes in intellisense, even suggests to create new class. What would cause this?
EDIT: I removed the project from TFS, and the classes are colored properly, and so is the intellisense. Perhaps some files are locked as checked in, and causes trouble?
Usually we do not suggest adding the BIN and the OBJ folders to source control, but do add the 3rd party dll's or using nuget package to handle them. Basically all that you need as input for your application is in source control, but the output of you application (the created dll's, pdb's etc) should not be included.
If you insist on this, first please double check you have add all related dlls in source control(check in them).
Then if your local build is successful and just the TFS build is failing
then it is usually due to dll reference path issue. Make sure that the
Dll is referenced as a relative path in the project file (.csproj).
Also give a try with adding the dll files into the bin folder where the builds located in TFS server. That .dll needs to be on whatever machine(build server) is running the build and the build definition needs to be pointing at that location.
Please take a look at this similar question: Namespace could not be found - building using TFS
I unticked readonly option from my .sln file.
I opened my .sln file with notepad and removed all the "GlobalSection" properties. (Related with TFS)
This solved the problem.

What is the best way to deploy a Template project in C#?

Heyy all =)
We create a custom project template in C# following This topic to force all developers to develop uniformly, all inherit from the same class and receive the same development tools we developed in four separate DLLs and all have the App.config file with default keys etc.
We work on vs2012 or vs2013.
Since I have put the DLLs manually and attach them to come into the same project ZIP file (are that is the right way to do it or somthing like this answare?) Now if there are any changes we will have time to re-export it, etc. So we thought the installation project.
Now I'm not sure what type of project to use.
I saw that there are a number of options I will list below and I would love advice about the right, the best, and most appropriate way to do it:
Creating Extensions By Using the VSIX Project Template or other Extensibility projects
The WIX way
Using Wizards somthing like this perfect answare
One of the project from the Visual Studio Installer Projects Extension

How to precompile ASP.NET 4.0 to a Single DLL with VS 2010

I recently upgraded from VS 2003 where I was working on a ASP.NET 2.0 website to VS 2010 where I have migrated to ASP.NET 4.0. So far it has been a big headache to get my site compiling with the new version. One problem was that my aspx.cs pages could not find the shared code libraries in my project. I solved this by moving my shared code to the App_Code folder (if there's a different/better way to do it please let me know).
Another issue that I am finding confusing is with pre-compilation. With VS 2003 I could click the build project button and it would precompile my site into a myweb.dll and myweb.pdb files. Now I'm having trouble doing the same in VS 2010. When I build the site in VS 2010 the dll is not created. I did manage to find an option to "Publish" the site which takes forever (like 2 minutes) and involves duplicating the site to another folder. This would have been acceptable but instead of making the single DLL file, it makes a bunch of files: App_code.compiled, app_code.dll, App_code.pdb, App_global.asax.compiled, App_global.asax.dll, App_global.asax.pdb, App_Web_lrpcway1.dll, App_Web_lrpcway1.compiled, App_Web_lrpcway1.pdb.
The application works - I can deploy it with all these files. However, I'd really like someone to explain what are the extra files and if there is a better way how to do it.
Thanks
This is the difference between a website and a web application.
You can convert your website to a web application to have it
behave more like you are used to.
The files in appCode are compiled when required to run and thus
does not provide dll.s in the bin/debug folder, but they should
be created when the application actually runs (but it is not
put in the same location).
Here is a nice write up about it Link
You can use the ASP.NET Merge Tool to combine all of the little DLLs into one big one.
http://msdn.microsoft.com/en-us/library/bb397866.aspx

Solution file vs. Project file in Visual Studio

Can someone briefly explain to me the difference between Visual Studio's solution file (.sln) and project file (.vcproj).
It seems to me opening either one open the correct solution/project in Visual Studio. Is one the super-set of the other?
Note: I am currently using Visual Studio 2008 working on a project that was brought forward from Visual Studio 2005 (I believe).
A solution is a set of projects. If you need more than one project in your software, then go with solutions. I.E.: A Class Library Project + A Web Application Project.
A project file typically corresponds to a single module: EXE or DLL or LIB. A solution manages a collection of project files.
A solution is a collection of projects. Visual Studio is made so that it cannot function without a solution, so if you open a bare project, it will generate the solution automatically (or try to find one).
One solution can contain zero or more projects. Everything is in projects, so a solution with zero projects doesn't contain anything at all besides the solution properties.
Visual studio keeps track of where the projects are used, so if you open a project file, it will open (IIRC) the last solution where it was used.
When you create a project from scratch, a solution is also created, but it's not shown until you add another project to it. It looks like you have only the project open, but it's actually a solution containing the project that is open.
Specifically project files are intended to contain the data required to build the files in the project into an exe or dll. This file is utilized by the local compilers or with systems such as Team Foundation system and server side build agents.
Solutions are a client (IDE) construct designed to manage collections of projects, which in effect is a collection of different build definitions and associated files.
Solution files are typically made up of multiple project files.

Icon of project in Visual Studio

I want certain projects in my solution opened in Visual Studio have different icons..Just like how Visual Studio displays different icons for class project, web site project etc
I am not talking about changing the icon of the winforms or other such app being produced
I understand I should arrange my code into proper namespaces / folder structure...and can even arrange the project into solution folders...but above will communicate better to my teammate for time being...(unfortunately we have inherited a reasonable code base and things needs to be cleaned along further development)
If you look in your SLN file, the project has a guid assigned to it.
all the c# projects have
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
and all the build folders have ..
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}")
These define the project type, which you can hunt down in your registry ....
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects
With this finding, I would say what you are looking for is VERY possible, but you'll have to create custom project types for visual studio. This may not be as daunting as it sounds, if you start with on of the default packages.
Here is a pointer to a sample, where in fact they mention setting the custom icon in step 3.
Building a Custom Project Wizard in Visual Studio .NET

Resources