Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / May 2004

Tip: Looking for answers? Try searching our database.

Specified cast is not valid after closing and opening solution

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank Hileman - 27 May 2004 20:01 GMT
Hello,

We have an assembly load problem with a custom root designer we have
constructed. We separated our designer classes and run-time classes into two
separate dlls, and put them in two separate directories upon installation.
Both of the directories are added to the registry at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders

Everything works fine when Visual Studio is opened and classes of type
Picture are edited: our root designer is loaded, and the root component
Picture can be edited.

A problem occurs if the solution is closed, but Visual Studio is not closed.
If you open a Picture, activating a designer, then close the solution, and
open another solution, Visual Studio can no longer open the designer for
Picture. The following error message appears:

Specified cast is not valid.

Tracing the exception down in the debugger, we found that the assembly
containing the root component, Prodige.Drawing.dll, is loaded twice inside
internal Visual Studio code, using LoadFrom. The error occurs because the
two loads of Prodige.Drawing.dll are not seen as the same assembly, and
therefore we actually have two identities for the Picture type; that is
simply the way LoadFrom works. The designer then cannot work with the second
load of the Prodige.Drawing.dll

This problem is caused by the shadow copies created by Visual Studio .NET.
If there is some way to reuse the same cache copy, or to avoid the cache
creation, we could eliminate the problem. Setting CopyLocal to false does
solve the problem, but it is not a good solution, since we do not use the
GAC (as recommended by MS), and Prodige.Drawing.dll must be redistributed
with any other output assemblies.

Overall, this seems to be a design flaw in Visual Studio. It works fine for
the root designers built into the .NET Framework, because they always use
the GAC for the assemblies containing the root components. But it does not
work well for any custom root designers.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
"Ying-Shen Yu[MSFT]" - 28 May 2004 07:31 GMT
Hi Frank,

Thanks for your insight!

I'll forward your feedback to the VS designer team and let them review it.

If you have any updates to this issue or meet some other issues in VS.NET
please feel free to let me know.

Thanks!
Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
"Ying-Shen Yu[MSFT]" - 31 May 2004 02:46 GMT
Hi Frank,

I got the reply from Brian:

Frank -- You are correct in your assessment here.  Visual Studio tries to
infer if it should shadow copy the assembly, and it does this by looking at
the CopyLocal
bit.  This bit is automatically set to "false" for GAC assemblies.  

I think you've covered both work-arounds:  either install your design time
assembly to the GAC or have your users set CopyLocal to false.  We are
looking at ways
to change this behavior in Whidbey

Thanks,
Brian Pepin.

If you have any further questions on this issue, please feel free to reply
in this thread!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.