Activity works in library but not in project

Hi,

I have a problem that is similar to the one that was described in: Activity working from workflow in library, but not when that library is called from a process

We have a xaml Workflow that is called by a coded c# automation. The code for that call is the following: _workflows.WorkflowInvocationService.RunWorkflow("C:\\Solutions\\Libraries\\LeasmanLibrary\\LeasmanBaseFunctions\\ReadPDFFiles.xaml", inputs);

The automation works fine while called inside the library but when the function that contains this call is called from the project the following error appears:

System.InvalidOperationException: Der ..\Libraries\LeasmanLibrary\LeasmanBaseFunctions\ReadPDFFiles.xaml-Workflow wurde nicht gefunden. Stellen Sie sicher, dass er Teil des Projekts ist.
at UiPath.Executor.WorkflowLoader.LoadWorkflow(String xamlPath, String compiledWorkflowAssemblyName)
at UiPath.Executor.InProcessRunner.BeginExecute(AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory1.FromAsyncImpl(Func3 beginMethod, Func2 endFunction, Action1 endAction, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TResult](Func3 beginMethod, Func2 endMethod, Object state)
at UiPath.CodedWorkflows.Utils.WorkflowExecutorExtensions.<>c__DisplayClass2_0.b__1()
at System.Windows.Threading.DispatcherOperation1.InvokeDelegateCore() at System.Windows.Threading.DispatcherOperation.InvokeImpl() --- End of stack trace from previous location --- at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout) at System.Windows.Threading.Dispatcher.Invoke[TResult](Func1 callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke[TResult](Func1 callback) at UiPath.CodedWorkflows.Utils.WorkflowExecutorExtensions.ExecuteWorkflow(IWorkflowExecutor workflowExecutor, Boolean canUseDispatcher) at UiPath.CodedWorkflows.WorkflowInvocationService.RunWorkflow(String workflowFilePath, IDictionary2 inputArguments, Nullable`1 timeout, Boolean isolated, InvokeTargetSession targetSession, String assemblyName)
at LeasmanLibrary.LeasmanMainScreen.Request.CheckRequestPdfData(String addressNumber, String contractNumber, String leasingObject, String fileName)
at TAS_Leasman.TC054894.TC053725.Execute() in C:\Solutions\TAS_Leasman\TS054894\TC053725.cs:line 56 ist in Execute aufgetreten.

Is seems like the workflow was not found even though the whole path was appended. Relative paths like LeasmanBaseFunctions\ReadPDFFiles.xaml dont work as well.

Thank you in advance for your help!

@testEng

First thing, May I know why you want to call a static xaml outside the project/library from your library?

cheers

The xaml ist a UiPath workflow that reads pdfs. So its a lowcoded workfow that contains UiPath activities. The workflow is part of the library.

@testEng

Can you please elaborate or show some screenshots

cheers


This is a picture of the workflow i try to call. It works fine as long as i call it inside the library. But when i publish the library and use that library in another project than the workflow is not found as shown in the error.

The calling structure is the following: In the other project a method of the library is called. Internally that methods calls the workflow that causes the problem. I hope that makes the situation clearer.

It should work with a relative path. Have you tried with LeasmanBaseFunctions\\ReadPDFFiles.xaml?

@testEng

if the workflow is in the same library then you need to use relative path ..

as the runtime they run from different folders and the path you provide might not be present on target system as well

cheers

I have altered the path so that it is now a relativ path like efelantti recommended. The error is still there

 var result = _workflows.WorkflowInvocationService.RunWorkflow("LeasmanBaseFunctions\\ReadPDFFiles.xaml", inputs);

Can you try with RunWorkflow from CodedWorkflowBase instead of _workflows object? Ie.

 var result = RunWorkflow("LeasmanBaseFunctions\\ReadPDFFiles.xaml", inputs);

That does not work also sadly, it leads to this error :System.NullReferenceException: Object reference not set to an instance of an object.
at UiPath.CodedWorkflows.CodedWorkflowBase.RunWorkflow(String workflowFilePath, IDictionary2 inputArguments, Nullable1 timeout, Boolean isolated, InvokeTargetSession targetSession)
at LeasmanLibrary.LeasmanMainScreen.Request.CheckRequestPdfData(String addressNumber, String contractNumber, String leasingObject, String fileName)
at TAS_Leasman.TC054894.TC053725.Execute() in C:\Solutions\TAS_Leasman\TS054894\TC053725.cs:line 56 ist in Execute aufgetreten.