Reference an internal class from a Windows Workflow Activity
I'm creating a custom Workflow activity for use within TFS2010. In the same assembly I have a XAML activity and a C# code activity. The XAML activity references the code activity.
When the assembly is deployed to our clients, I only want them to be able to use the Workflow activity. The code activity is of little use by itself and would no doubt confuse them.
I thought the logical way to do this would be to set the code activity class to internal: the XAML is in the same assembly and should be able to access it. However, when I do that I get an error in the XAML saying that the type can't be found in the assembly.
开发者_开发百科Is there a way to make activities internal/hidden?
This is a common problem with XAML in all its forms. It's caused by the fact (mentioned in one of the comments) that the parser isn't in the same assembly, so has no access to internals of your assembly.
The work-around that I've seen most frequently is just to separate out what you'd like to have as internal into its own namespace. At least then your consumers aren't typically bothered by confusing types that they don't need to use. In WPF this namespace is usually the main namespace with ".Primitives" appended to it. e.g. System.Windows.Controls.Primitives.
Another tack that you could investigate is using a custom NativeActivity rather than a XAML one. Presumably this could use internal classes, since the XAML parser isn't involved. I've not tested this out though.
精彩评论