Groups | Blog | Home
all groups > visual studio .net ide > march 2004 >

visual studio .net ide : VS .NET 2003 cannot display a VB form


Norman Diamond
3/9/2004 11:01:08 PM
In Visual Basic .NET 2003, I tried to open form frmMain.vb. Visual Studio displayed the following error instead of the form:

ドキュメントを読み込み中にエラーが発生しました。このエラーを修正してから、再びドキュメントを読み込んでください。エラー メッセージは以下の通りです。

オブジェクト 'System.Windows.Forms.Design.FormDocumentDesigner' のプロパティ アクセサ 'IsMdiContainer' が以下の例外をスローしました :'指定されたキャストは有効ではありません。'

Visual Studio .NET 2003 could not open document frmMain.vb, says I should correct this error and then try again to read the document. The error is that object 'System.Windows.Forms.Design.FormDocumentDesigner' property accessor 'IsMdiAccessor' specifies a cast which is not valid. Here, Visual Studio .NET 2003 is telling me to correct it. Does anyone know how I can correct this error?

In Notepad, I looked at the form's source code, and there are no occurrences of System.Windows.Forms.Design.FormDocumentDesigner. System.Windows.Forms.Form and System.Windows.Forms.Button yes, but no System.Windows.Forms.Design.anything. No occurrences of IsMdiAccessor either. Nonetheless Visual Studio .NET 2003 insists I must correct this error.

The project is a small one and can be downloaded from http://home.att.ne.jp/star/ndiamond/Solution1.zip

(Also: Visual Studio .NET 2003 did not allow the mouse to copy and paste the error message. Japanese isn't my best language, but I managed to read it and type it back in exactly. Surely it would be better to let the mouse copy it.)
v-phuang NO[at]SPAM online.microsoft.com (
3/10/2004 9:47:28 AM
Hi,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that one of your project will got error
messge in design time in a winform application as below.

"System.Windows.Forms.Design.FormDocumentDesigner' property accessor
'IsMdiAccessor' specifies a cast which is not valid"

Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my research, you have set the System.Windows.Forms assembly(which
is located in the GAC and strongnamed)'s copylocal property to true which
cause the problem. I suggest you right click on the System.Windows.Forms
under the references in your project and select properties, change the copy
local property to false and rebuilt the project and close the project.

Then you reload the project into VS.NET to see if the problem persists.

Please apply my suggestion above and let me know if it helps resolve your
problem.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Norman Diamond
3/10/2004 4:31:07 PM
[quoted text, click to view]

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that one of your project will got error
messge in design time in a winform application as below

"System.Windows.Forms.Design.FormDocumentDesigner' property accessor
'IsMdiAccessor' specifies a cast which is not valid

The meaning is the same, though of course I could not say what the exact English wording would be

Based on my research, you have set the System.Windows.Forms assembly(which
is located in the GAC and strongnamed)'s copylocal property to true which
cause the problem. I suggest you right click on the System.Windows.Forms
under the references in your project and select properties, change the copy
local property to false and rebuilt the project and close the project

Then you reload the project into VS.NET to see if the problem persists

v-phuang NO[at]SPAM online.microsoft.com (
3/12/2004 6:56:59 AM
Hi,

Thanks for your quickly reply!

This is a known issue, and I have reported it to our product team, but I
can not guarantee if it will be fixed in the next release of VS.NET.

The problem was caused by the fact that when you set the copylocal to true,
in the design time, the VS.NET IDE will not load the assembly from the GAC,
so even the two assemblied are the same binary files but their full
qulified name are not the same(i.e. the path is not the same). So that
there will be a mismatch which cause the problem. However in the runtime,
(i.e. Press Ctrl + F5 to run the winform app) we will not get the error
because the system.windows.forms.dll is loaded from the GAC.

For your concern about the internationlization, if the assembly is in the
GAC, I think we do not need to set the copylocal to true, since in the run
time, the CLR will try to load the assembly from the GAC first. As for the
other assembly which is not placed in the GAC, it is proper to set the
copylocal to true, which will help to make sure the application will load
the correct assembly.

For now, I suggest try to set the copylocal to false to workaround the
problem.

Here are some links.
How the Runtime Locates Assemblies
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconhowruntimelocatesassemblies.asp

CopyLocal Property (Reference Object)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vxlrfvslangprojreferencecopylocal.asp


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button