By Greg McGuffey - 10/26/2009
I've written a UITypeEditor and it works when the editor lives in the same assembly (or one of the referenced assemblies) as the types using it. Then I can use something like:
[Editor(typeof(MyUIEditor), typeof(UITypeEditor))]
public MySpecialType SpecialType { get; set; }
However, I'd like to move this to a separate assembly, one that is not referenced by the assemblies with types that use it, because I don't want to have to distribute the code that is solely to for the VS designer. I know this can be done, as SF does this quite nicely. I've attempted to figure out how it was done (looked at SF code) and then I tried this:
[Editor("MyProject.Extensibility.MyUIEditor, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e54367fa007b34d2", typeof(UITypeEditor))]
public MySpecialType SpecialType { get; set; }
with the extensibility assembly copied into the bin\debug folder with the main project. No joy.
How is this done? What am I missing? Can this be done if the assembly isn't strong-named?
|
By Trent L. Taylor - 10/26/2009
You are going down the right path here. All of our type editors are in the Extensibility assembly which actually references the SF assemblies. So obviously the SF assemblies can not directly reference the Extensibility assembly otherwise it would create a circular reference. That is when you use type naming instead of type references (as you are trying to do).
Your editor naming looks spot on, so the next thing I would check would be any assemblies in the local folder, bin folder, etc. that could be getting referenced incorrectly. Next, to debug this, just create a test program with a reference to the assembly in question (that has the type editor) and then use the Activator.CreateInstance call to attempt to create an instance. If you can make this happen, then it will work within the Editor as well.
Finally, you may have to use the GAC if you cannot make the logical path work.
|
By Greg McGuffey - 10/28/2009
Thanks Trent. That got me going again. It turns out that you can set up a registry key for this sort of thing if the GAC isn't desired. This question (by me) on StackOverflow provides the details.
http://stackoverflow.com/questions/1628264/how-is-an-assembly-resolved-at-design-time
Debugging these UITypeEditors is...er...fun. I finally figured out that I had an issue with my test type editor when VS wouldn't let me build the extensibility project because it was in use by another process. Hmmmm...so VS was finding it, but there was an error. Once I got that ironed out, it worked.
Now I've just got to get the real one working!
|
By Trent L. Taylor - 10/28/2009
Testing them is actually really easy. All you need to do is set the DevEnv.exe as the debug program from your extensibility project. Then once the new devenv.exe instance is opened as part of the debug session, you open a project that you want to test. Then you can debug it just like you would anything else. Makes it super easy!
|
By Greg McGuffey - 10/28/2009
Hah!!! I got it working! A couple of further notes, for anyone who might later need this (including me!):
1. The path in the registry needs a trailing backslash. I think this might have been one of my early problems.
2. After setting the path, restart VS. I'm pretty sure that it loads the paths when it loads.
3. Once you actually use the type editor in the designer, if you need to make a change, you'll need to exit VS, then reopen, make change, build, then test. Rinse. Repeat.
OK, I'm going to dance a bit of a jig now....
|
By Trent L. Taylor - 10/28/2009
Be sure and do it in front of your web cam so we can see
|
By Greg McGuffey - 10/28/2009
Trent L. Taylor (10/28/2009) Testing them is actually really easy. All you need to do is set the DevEnv.exe as the debug program from your extensibility project. Then once the new devenv.exe instance is opened as part of the debug session, you open a project that you want to test. Then you can debug it just like you would anything else. Makes it super easy!
I'm a bit slow. This is like the 100th time this has been explained to me, but with this post, the light bulb finally went off. I had another question and Paul explained how to do this exact thing, but I didn't quite get it. Then I realized that I needed a separate solution for the extensibility project (duh!) (not strictly required, but then it is just setup and ready to go) and it all made more sense and I got it to work!
Here is Paul's post that explains how to actually do what Trent just said!
http://forum.strataframe.net/FindPost24961.aspx
|
By Edhy Rijo - 10/28/2009
Greg McGuffey (10/28/2009) I'm a bit slow. This is like the 100th time this has been explained to me...
Guess that comes with the aging process
It is happening to me more frequently
|
By Greg McGuffey - 10/28/2009
I prefer to think of my aging process as something more like fine wine, just getting better with age....
My mother used to say senility was hereditary....you get it from your kids! I'm starting to believe her (I have a 13yr old daughter...and the gray hairs are multiplying!).
Oh, and fortunately, for y'all, no web cams were present during the jig!
|
|