views:

171

answers:

4

I have a WF4 custom activity with a custom designer (WPF). I would like to have slightly different behaviour in the CacheMetaData override depending on if the Activity is in Design or Execution mode.

Edit: Reasons for requirement. We have validation that needs to look up the data from the web.config file (or one of its includes). At run time we can use System.Configuration.ConfigurationManager, and at design time I need to use EnvDte to interrogate the project structure.

Since the Activity can be debugged, it could in be VS in either case so I cannot check for that.

Is there a service within WF4 I can call to tell what mode I'm in please?

A: 

As far as I know there is no good way of doing so.

You can check using the process name. If it is devenv you are in Visual Studio (if you are debugging it will be your project name with .vshost tagged on. But as the designer can be re hosted that is far from reliable.

Maurice
A: 

Could you please describe in more detail how/why you want CacheMetaData to behave differently at design time?

kreinsch
I've added the reason to the question
Preet Sangha
A: 

One thing you could do is to actually have a separate design time activity from your runtime activity. This is what I'm doing. Takes a bit of work and might be overkill for your needs. Check out this WF forum post for more details.

Notre
thank you I'll check it out
Preet Sangha
A: 

If the reason for this requirement is purely validation couldn't you move the validation logic requiring EnvDTE to the designer component, leaving just the runtime validation logic in the activity itself?

Jimit