public void ExampleCompileAndExecuteWF()
{
String[] sources = new String[] {
"..\\..\\..\\WFActivityLibrary1\\MyActivity.xoml",
"..\\..\\..\\WFActivityLibrary1\\MyActivity.xoml.cs"
};
String[] references = GetReferencedAssemblyFileNames();
String[] libraryPaths = GetReferencedAssemblyPaths();
String activityTypeName = "MyActivity";
Dictionary<string, object> namedArgumentValues =
new Dictionary<string, object>();
namedArgumentValues.Add("WorkflowArgument", "test");
CompileAndExecuteWF(sources, references, libraryPaths,
activityTypeName, namedArgumentValues);
}
private string[] GetReferencedAssemblyPaths()
{
List<String> list = new List<string>();
Assembly thisAssembly;
thisAssembly = Assembly.GetAssembly(this.GetType());
foreach (AssemblyName assemblyName
in thisAssembly.GetReferencedAssemblies())
{
Assembly assembly = Assembly.Load(assemblyName);
list.Add(Path.GetDirectoryName(assembly.Location));
}
return (list.ToArray());
}
private string[] GetReferencedAssemblyFileNames()
{
List<String> list = new List<string>();
Assembly thisAssembly;
thisAssembly = Assembly.GetAssembly(this.GetType());
foreach (AssemblyName assemblyName
in thisAssembly.GetReferencedAssemblies())
{
Assembly assembly = Assembly.Load(assemblyName);
list.Add(assembly.Location);
// list.Add(Path.GetFileName( assembly.Location));
/* If you use
* the "Path.GetFileName(assembly.Location)" version
* it will require to set appropriate paths
* and might lead to name-conflicts if assemblies
* with identical filenames exist in multiple
* directories
*/
}
return (list.ToArray());
}