dotnet windows forms designtime:
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