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 / April 2004

Tip: Looking for answers? Try searching our database.

UITypeEditor must be in the same assembly?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben R. Bolton - 01 Apr 2004 04:07 GMT
I have a WebControlLib project that defines a custom property editor which
works well for a property of a custom control in the WebControlLib assembly
but when I move the custom property editor class to different assembly the
IDE won't run the editor for the property.

The attribute for the property that I have been using is:

[
Editor(typeof(CustomEditor),typeof(UITypeEditor))
]

I, of course, had to add a reference to the new assembly (ClientLib.)

Do custom editors have to be defined in the same physical assembly as the
property that uses it?

I would like to move this custom editor out to a different assembly and make
it available to other projects.  Does anyone have any suggestions on how
this can be done?

Ben
Palo Mraz - 06 Apr 2004 11:34 GMT
Hi Ben,

I've made it work with WinForms designer, but hopefully it will
work with WebForms designer as well. Here are the steps I've used:

1. In your WebControlLib library, use the EditorAttribute constructor
that accepts the string type name of the type editor, e.g.:
[Editor("ClientLib.CustomEditor", typeof(UITypeEditor))]

2. In your ClientLib design library, add an *assembly* reference to
your WebControlLib from the appropriate output directory.

3. In order to debug the design time functionality of your editor,
you'll have to ensure that VS is able to locate your design assembly.
You'll have to either place the ClientLib.dll into the devenv.exe folder.
Or you could add the appropriate <dependentAssembly> and
<codeBase> settings pointing to your ClientLib assembly to the
devenv.exe.config file (this is the approach that I've used with my
WinForms design library). (Or you could place the design assembly
into GAC (provided it has a strong name), but I wouldn't recommend
that.)

Best regards,

Palo
Signature

http://dact.lamarvin.com/
AutoComplete component for WinForms applications. Easy to integrate, easier
to use!
http://www.vbinfozine.com/
An ordinary VB developer shares his own successes and failures

Ben R. Bolton - 08 Apr 2004 17:30 GMT
Thanks Palo,

1)  I've had problems with using typeof to get a type at compile time that
doesn't work at design time before.  Can you explain why using

[Editor("ClientLib.CustomEditor", typeof(UITypeEditor))]

works, while

Editor(typeof(CustomEditor),typeof(UITypeEditor))

compiles but has problems at run-time?

2) I don't quite understand the suggestion for a reference.  CustomEditor is
defined in ClientLib and the control is in WebControlLib, therefore there
must be a reference to ClientLib in the WebControlLib project, creating
reference to WebControlLib from ClientLib would create an invalid reference.
Do you mean something different by an *assembly* reference?

Again, thanks for your assistance.

Ben

> Hi Ben,
>
[quoted text clipped - 21 lines]
>
> Palo
Palo Mraz - 14 Apr 2004 22:40 GMT
> 1)  I've had problems with using typeof to get a type at compile time that
> doesn't work at design time before.  Can you explain why using
[quoted text clipped - 6 lines]
>
> compiles but has problems at run-time?

Could you be please more specific? What kind of problems at runtime
do you have?

> 2) I don't quite understand the suggestion for a reference.  CustomEditor is
> defined in ClientLib and the control is in WebControlLib, therefore there
> must be a reference to ClientLib in the WebControlLib project, creating
> reference to WebControlLib from ClientLib would create an invalid reference.
> Do you mean something different by an *assembly* reference?

The point here is that your designer assembly (ClientLib) references your
control
assembly (WebControlLib), but your control assembly *doesn't* reference your
designer assembly. This way, the control assembly doesn't have the designer
assembly
as a dependence in its manifest, so it should be loaded and executed with no
problems
at runtime. At design time, when the VS.NET designer host instantiates your
control,
it will try to instantiate the designer based on its the type name, as
specified by the
EditorAttribute attribute. Therefore, the designer assembly has to be
available to the
executable, which devenv.exe.

Obviously, the designer has to communicate with the control somehow . If
they're in the
same assembly, they can use Friend (internal) methods. But if they're
separated *and*
the control assembly doesn't know anything about the designer (except its
string type name),
there must be some mechanism how the designer communicates with the control
being
designed. Because the designer assembly *does* reference the control
assembly, it can
use the control's public interface. If the designer wants to employ some
"nonpublic"
exchanges with the control during design time, I'd suggest defining an
EditorBrowsable(Never)-interface defined in the control's assembly, which
the designer
assembly could use. If you'd like to be secure, you could probably sign your
assemblies
and apply the StrongNameIdentityPermission to the designer-only interface
methods (as
explained in
http://msdn.microsoft.com/msdnmag/issues/04/04/SecurityBriefs/default.aspx),
but
I don't have practical experience with it.

HTH

Best regards,

Palo
---
http://dact.lamarvin.com/
AutoComplete component for WinForms applications. Easy to integrate, easier
to use!
http://www.vbinfozine.com/
An ordinary VB developer shares his own successes and failures

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.