Problems of designer file in asp.net - c#

Whenever I open an existing project in VS 2005, the designer.cs files do not show up under .aspx files, and due to this when I add controls in .aspx the designer.cs is not updated.
Below is how the structure looks:
+----AAAConfirm.aspx
. .
. ..AAAConfirm.aspx.cs
.
.----AAAConfirm.aspx.designer.cs

You need to "show all files" for the project, it most likely got removed from the project file by accident. When you see the file in Visual Studio, right click the file and select "Add to Project".
Or
Check the project file and make sure the designer file's compile tag has a child element called DependentUpon
The XML section specifying the file's inclusion in the project should look something like this
<Compile Include="AAAConfirm.aspx.designer.cs">
<DependentUpon>AAAConfirm.aspx</DependentUpon>
</Compile>
Also check that the markup page AAAConfirm.aspx has the correct codebehind and inherit reference in the <%Page> tag. Did you maybe change namespaces? Try setting the Inherits attribute value to the class name without the namespace.

Copy your project to some other folder and
Locate the corrupted aspx.designer.cs file through the Solution
Explorer Delete only the designer.cs file from your project
Rightclick your main aspx file and select “Convert to Web
Application“.
Ref : Tip: regenerate aspx.designer.cs files when corrupted

Related

Visual Studio 2017 can't find folder that exists in the solution

I have Visual Studio 2017 project in which I need to open a folder named Devdog.General, which is also included in my Solution. However, it won't recognize it as an existing folder and gives me a missing directory / namespace error when I try to import it. See screenshot for more info.
Try this button:
I had a similar problem the other day and it had to do with files that Visual Studio didn't know were part of the project because they'd been created externally (and that included folders). Visual Studio could see them but it was hiding them from me.
After clicking that button, you will be able to right click on the folder and select "include in project" which will include the files for compilation and navigation.
First, try selecting any of your "*.cs" files inside this "General" folder and check in the "Properties" view if the Build Action is configured to Compile. Visual Studio will only compile your file if it has the correct build action.
Secondly, open that "*.cs" file and verify if the namespace defined inside it is correct. For C#, folder structures don't matter much: what really matters is the namespace you have defined your classes in. You can define your classes in namespaces completely different than the folder they are included in your project. That is completely arbitrary, and up to your organizational needs.
An image illustrating what you need to check (and where) follows.
Things to Check
1.) Check the namespaces inside .CS files - they collectively create usable namespaces you are referencing - not folder names. If you create a few files, then move them to a folder, and create newer files inside that folder they will have different namespaces. The newer files will have the default Namespace value followed by .FolderName. So be sure to check that out.
2.) CSPROJs can get hosed and lose reference to folders that display in the UI. Remove the folder from the project (through the VS2017 UI, right click and choose that option). DO NOT DELETE. Then recreate the folder in the UI (it shouldn't let you, navigate to the folder directory manually and rename the folder.OLD temporarily). Once the folder is rename, try recreating the folder. Upon success move all your CS files into the new folder from folder.OLD. After files and folders are back to where they were essentially, then in Visual Studio, "Add existing items" on your .cs files. This recreates the CSPROJ references one by one.
3.) Unload CSPROJ, right click and Edit CSPROJ to manually check all the .CS references in ItemGroups. Make sure its myfolder\myotherfolder\mycsfile.cs.
4.) Remove reference to other projects that contain namespace, and re-add them. Verifying, one by one, the namespaces begin reappearing in Intellisense as recognized.
5.) If you try the above step, close Solution, close Visual Studio, navigate to SLN folder container, and delete hidden folder .vs and then reopen everything.
What happens is sometime a folder rename or file transfer doesn't propagate to the .CSPROJ folder, a namespace then doesn't get intellisense cached, and errors galore show up.
Please check your folder name and namespace name. probably folder name and namespace did not match
enter image description here

designer.cs not showing in solution

I'm using Visual Studio Community 2015 and need to view the designer.cs file for one of my webforms. However, when I expand the aspx file in the solution explorer, it does not show up. How do I force Visual Studio to show me the designer.cs file?
Here's what I see in Solution Explorer:
Also, I seem unable to edit the project file (.csproj) by hand so that it will show the designer.cs file because I can't find the project file in the folder containing the code. Here's a screenshot of that folder:
Folder Contents
In order for a designer file to show up beneath a source code file within the Project Explorer, the project file (.csproj) must have an entry as follows:
<Compile Include="page.aspx.cs">
<DependentUpon>page.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="page.aspx.designer.cs">
<DependentUpon>page.aspx</DependentUpon>
</Compile>
Please open your ProjectName.csproj file and check to see that this pattern exists for your source file (.cs) and designer source file (.designer.cs).
You will have to unload and then reload your project from Visual Studio for changes to the Project File to take effect.
Per Dave in the comments above - It appears that your project is configured as a web site instead of a web application. I would recommend that you convert your project to a web application by creating a new project and re-adding the files. You can read up on the differences between the two models here on MSDN

unable to view designer of windows form added as existing item

I have added a windows form to my visual studio 2013 project by using the option "Add an existing item". I only add the .cs file in the project and the rest of files (.Designer.cs, *.resx) are generated automatically.
I can view the code but i m unable to view designer of this form. (i cant edit form by using toolbox).
Any solution for this..??
Thanks
The best way to this is:
Add the windows form files (.cs, .designer.cs and .resx) to a
directory in your solution, using windows explorer.
In the VS solution explorer make sure you set the 'Show all files' option.
Refresh the solution explorer using the refresh button.
Right click the file (which should already been recognized as windows form) and choose 'Include in project'
i found a solution.. All u need is to add the .cs file of the windows form (.designer.cs and .resx files will be added automatically). then close your solution and reopen it after a while. Your .cs file will be recognized as windows form by visual studio...
Open the project file (yourproject.csproj) in your favorite text editor.
Ensure that the entry that references the form in the project has a subtype of "Form".
Steps:
Locate the line that includes said form in the project.
<Compile Include="Forms\Login.cs" />
Change to:
<Compile Include="Forms\Login.cs" >
<SubType>Form</SubType>
</Compile>
Save the csproj file and open the project/solution.

.designer file not being associated with .cs file in visual studio?

EDIT:
There seems to be a visual (?) bug in visual studio. When I opened my website folder as a website and looked at my Views.ascx.designer.cs it doesn't show that it is associated. However, if I open that same website's solution file then the files are associated and all is well.
Just to be clear, even though it is still showing the below error messages it is working and I believe that it's a bug with opening it as a website instead of as a solution.
On my live site I have an error:
But it should exist because I have it in my Views.ascx.designer.cs:
But in Visual Studio my Views.ascx.designer.cs is not being associated with my View.ascx:
I tried to drag and drop the .designer file onto View.ascx but it displayed this error message:
It works and looks perfectly fine on my dev server:
I'm not sure how I would go about getting the file to associate itself with the View.ascx or View.ascx.cs files.
First step: right-click the files and exclude them, and try including them back in. It may fix itself. If not, you could edit the project directly; you just to add the dependency that the CSPROJ or VBPROJ expects. Here is an example that you need to make sure is in the project XML:
<Compile Include="Views\Main.aspx.designer.vb">
<DependentUpon>Main.aspx</DependentUpon>
</Compile>
<Compile Include="Views\Main.aspx.vb">
<DependentUpon>Main.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
Have had the same issue while adding form from other project to the pending one , I've excluded both files then added back by adding non-designer file 1st and .Designer.cs was then added in the right place automatically from the same catalogue as .cs file (VS2012).

Cannot load project by opening .csproj

Sorry, i am new to VS... :'(
I am currently using VS2010. When i am trying to double-click a .csproj to load a project, it just load a XML instaed of all the associated .cs / properties / reference files. I did previously can load other projects with .csproj. So i am wondering if it's related to the project itself.
Any way I can spot/check the reason/root-cause of it? (from the XML file loaded?)
Is it because the project is previously developed using other older VS, like VS2008 / VS2005?
Thanks.
Maybe you have accidentally changed the default file association of your .csproj files. Go into the Control Panel -> Default Programs -> Set Associations to see what application is set to open the file and change it to Visual Studio.
Click Start, and then click Control Panel.
Click Folder Options.
Click File Types tab in Folder Options window and the full file
types and their association will be listed.
Click New and type the File Extension in the box and then click
Advanced.
Choose an association for the file type.
Click OK and then Click Close.
Open the file again

Categories

Resources