Invoke Code Error - Namespace

I’m invoking this below code using Invoke Code activity by setting Language as CSharp. Please find the code and error details below. Kindly help me to fix this issue.

using System;
using System.Diagnostics;

class Program
{
static void Main(String args)
{
// Path To SpreadsheetCompare.exe And Excel files To compare
string spreadsheetComparePath = @“C:\Program Files\Microsoft Office\root\Office16\DCF\SpreadsheetCompare.exe”;
string file1Path = @“C:\path\to\file1.xlsx”;
string file2Path = @“C:\path\to\file2.xlsx”;

    try
    {
        // Start SpreadsheetCompare.exe process In the background
        Process process = new Process();
        process.StartInfo.FileName = spreadsheetComparePath;
        process.StartInfo.Arguments = $"\"{file1Path}\" \"{file2Path}\"";
        process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        process.Start();
        process.WaitForExit();

        // Check If SpreadsheetCompare.exe exited successfully
        if (process.ExitCode == 0)
        {
            Console.WriteLine("Comparison completed successfully.");
        }
        else
        {
            Console.WriteLine($"Comparison failed. Exit code: {process.ExitCode}");
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine($"An error occurred: {ex.Message}");
    }
}

}

No compiled code to run
error CS1001: Identifier expected At line 1
error CS1001: Identifier expected At line 2
error CS1513: } expected At line 2
error CS1022: Type or namespace definition, or end-of-file expected At line 40
error CS0118: ‘System’ is a namespace but is used like a type At line 1
error CS0210: You must provide an initializer in a fixed or using statement declaration At line 1
error CS0118: ‘System.Diagnostics’ is a namespace but is used like a type At line 2
error CS0210: You must provide an initializer in a fixed or using statement declaration At line 2

Hi,

We cannot define class in InvokeCode. The following may help you.

Regards,

Thanks for the quick response, please tell me how to invoke the coded workflow that was created. As I’m unable to run the codedworkflow.cs also unable to invoke and run from a different xaml

image

Hi,

It seems there is no workflow in Workflow.cs. If you just define class in it. it’s unnecessary to use InvokeWorkflowFile. You can use the class in Assign or InvokeMethod etc.

Regards,

Thanks again. Let me try

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.