Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2010 VC++
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
#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
#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 16-Feb-13 22:09pm
Edited 17-Feb-13 7:57am
ProgramFOX132.4K
v3
Comments
Richard MacCutchan at 17-Feb-13 3:20am
   
Does this happen on a new project or only existing ones?
Richa Vats at 17-Feb-13 3:23am
   
This is happening to an already existing project.....
Richard MacCutchan at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v7
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

remove files at the vsprojet.
later reload the files.try again.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 295
2 Sergey Alexandrovich Kryukov 197
3 Peter Leow 155
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 7,510
1 DamithSL 5,494
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 30 Oct 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100