Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
An Exception of type System.Exception was thrown when I am trying to open an already created window form in designer mode. This problem is coming when I am trying to open any window form which I have already created, in designer mode. I don't know why this error is coming. I need to edit my forms but I am not able to do so.. Please help me.......

This is the call Stack output in designer mode.....
at VSLangProj.Reference.get_Path() at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_FileName() at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.GetMatchIndex(String typeName) at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchNormalEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, Boolean fastSearch) at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchEntries(AssemblyName assemblyName, String typeName, Boolean ignoreCase, Assembly& assembly, ReferenceType refType) at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType) at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name) at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String typeName) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)

Below is one of the form's header file and its C++ file code.....

WelcomeWindow.h
C++
#ifndef WELCOMEWINDOW_H
#define WELCOMEWINDOW_H

#pragma once

#include "test_open.h"
namespace open_image {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for WelcomeWindow
	/// </summary>
	public ref class WelcomeWindow : public System::Windows::Forms::Form
	{
	public:
		WelcomeWindow(void);

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~WelcomeWindow();

	private: System::Windows::Forms::Label^  label1;
	protected: 
	private: System::Windows::Forms::Button^  continue_btn;
	private: System::Windows::Forms::Button^  exit_btn;


	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(WelcomeWindow::typeid));
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->continue_btn = (gcnew System::Windows::Forms::Button());
			this->exit_btn = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->BackColor = System::Drawing::SystemColors::GrayText;
			this->label1->Font = (gcnew System::Drawing::Font(L"Monotype Corsiva", 21.75F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)), 
				System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
			this->label1->Location = System::Drawing::Point(0, 0);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(136, 36);
			this->label1->TabIndex = 0;
			this->label1->Text = L"Welcome...";
			// 
			// continue_btn
			// 
			this->continue_btn->BackColor = System::Drawing::SystemColors::GrayText;
			this->continue_btn->Font = (gcnew System::Drawing::Font(L"Bookman Old Style", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->continue_btn->Location = System::Drawing::Point(479, 402);
			this->continue_btn->Name = L"continue_btn";
			this->continue_btn->Size = System::Drawing::Size(81, 32);
			this->continue_btn->TabIndex = 1;
			this->continue_btn->Text = L"Continue";
			this->continue_btn->UseVisualStyleBackColor = false;
			this->continue_btn->Click += gcnew System::EventHandler(this, &WelcomeWindow::continue_btn_Click);
			// 
			// exit_btn
			// 
			this->exit_btn->BackColor = System::Drawing::SystemColors::GrayText;
			this->exit_btn->Font = (gcnew System::Drawing::Font(L"Bookman Old Style", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->exit_btn->Location = System::Drawing::Point(560, 402);
			this->exit_btn->Name = L"exit_btn";
			this->exit_btn->Size = System::Drawing::Size(65, 32);
			this->exit_btn->TabIndex = 2;
			this->exit_btn->Text = L"Exit";
			this->exit_btn->UseVisualStyleBackColor = false;
			this->exit_btn->Click += gcnew System::EventHandler(this, &WelcomeWindow::exit_btn_Click);
			// 
			// WelcomeWindow
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"$this.BackgroundImage")));
			this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
			this->ClientSize = System::Drawing::Size(630, 441);
			this->Controls->Add(this->exit_btn);
			this->Controls->Add(this->continue_btn);
			this->Controls->Add(this->label1);
			this->Name = L"WelcomeWindow";
			this->Text = L"WelcomeWindow";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void exit_btn_Click(System::Object^  sender, System::EventArgs^  e);
	private: System::Void continue_btn_Click(System::Object^  sender, System::EventArgs^  e);
	};
}
#endif


WelcomeWindow.cpp
C++
#include "stdafx.h"
#include "WelcomeWindow.h"
#include "test_open.h"
namespace open_image
{
	WelcomeWindow::WelcomeWindow(void)
	{
		InitializeComponent();
		//
		//TODO: Add the constructor code here
		//
	}
	WelcomeWindow::~WelcomeWindow()
	{
		if (components)
		{
			delete components;
		}
	}
	public ref class container
	{
		public:
			static test_open^ t = gcnew test_open();
	};
	System::Void WelcomeWindow::exit_btn_Click(System::Object^  sender, System::EventArgs^  e) {
		this->Close();
		exit(1);
	}
	System::Void WelcomeWindow::continue_btn_Click(System::Object^  sender, System::EventArgs^  e) {
		/*test_open^ t = gcnew test_open();*/
		this->Hide();
		container::t->Show();
	}
}
Posted
Updated 30-Nov-22 8:29am
v3
Comments
Richard MacCutchan 17-Feb-13 3:20am    
Does this happen on a new project or only existing ones?
Richa Vats 17-Feb-13 3:23am    
This is happening to an already existing project.....
Richard MacCutchan 17-Feb-13 3:35am    
Then it is quite probable that something in the project or the source file for the form, has become corrupted. Try recreating the project and see what happens.
Jibesh 17-Feb-13 4:00am    
check your form constructor and FormLoad event if used for any code which executes any method needs to be created or constructed. try to comment these lines and open the form.

let me know if you have any code written in those method

Most likely cause
A problem in the Form.Load event, something called from the Form.Load Event or some other code called during initialization (Constructor?)

Solution
The Form.Load event is executed in both Design Mode and when running the program. To prevent problems in Design Mode caused by code executing in the Form.Load event, do the following.

Put all of the code in the Form.Load event within an If statement like this:
if (!this->DesignMode) {
//
//
// All of the Form.Load event code goes here
//
//
}


See DesignMode Property[^] in the Visual Studio Help.
Remarks
The DesignMode property returns true to indicate that the control is being used in the context of a designer. Your custom controls can use this property when design-time behavior is different than run-time behavior.
 
Share this answer
 
v7
remove files at the vsprojet.
later reload the files.try again.
 
Share this answer
 
@OuYangXuChuan: Thanx For the solution. It Really helped me.
 
Share this answer
 
Comments
Deepu S Nair 25-Jan-15 1:42am    
Please don't post your comment as solution.Instead us 'Have a Question or Comment?' link
Go to project. Then properties and delete any duplicate references or those references with error they are usually marked with a red I notation delete them and reload your design sometimes you may need to reboot the system if it persists
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900