C# function call issue

10.2.100.16
I’m trying to do a proof of concept to call a function from a C# DLL in an Epicor customization. Below is the DLL source:

using System;

namespace TestLib
{
public class test
{
public int Twice(int a, int b )
{
b = a * 2;
return 0;
}
}
}

The DLL compiles successfully, I’ve copied the DLL to the client folder, added the reference through Assembly Reference Manager, and
refrenced the class in a using reference. Below is the code calling the function:

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
    try
    {
    // ** Place Event Handling Code Here **
    EpiNumericEditor numInputParm = (EpiNumericEditor)csm.GetNativeControlReference("3c5949cc-85db-4aee-afb4-e59a22dfbc0b");
    EpiNumericEditor numOutputParm = (EpiNumericEditor)csm.GetNativeControlReference("9834feac-aa4d-4fc4-8cda-f746b9cdca74");

    int lngOutput = 0;
    Test tst = new Test();
    int RC = tst.Twice(int.Parse(numInputParm.Text), int lngOutput);
    numOutputParm.Text = lngOutput.ToString();
    oTrans.Refresh;
    }

    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

However, when testing the customization, I’m getting errors on the line executing the function:

Compiling Custom Code …

----------errors and warnings------------

Error: CS1525 - line 68 (261) - Invalid expression term ‘int’
Error: CS1002 - line 68 (261) - ; expected
Error: CS1525 - line 68 (261) - Invalid expression term ‘)’

** Compile Failed. **

I’m very new to C# and E10, and I don’t see the issue with the code. Could anyone please help? Thanks!

It’s case sensitive. Change your source to be captial Test

2 Likes

Thanks, Chris! Collaborating with someone on the DLL, didn’t see the source code until now.

1 Like

Hey John,

new() is glue and creates dependencies that make upgrading more difficult. Any change in your DLL will have to be rolled out to multiple places. Have you considered writing this as a WebAPI instead?

Mark W.

1 Like

I agree with Mark. Unless there is tons of logic - it would be better suited built into the customizations as needed (essentially copy/paste) or another method as Mark suggests.

Chris/Mark, I think that’s the direction we’ll end up heading. We’re just trying to prove we can call a function outside of Epicor that is not bound to an Epicor DLL, so we can separate some of our more complex custom code from the system. Thanks for the input!

:1st_place_medal:
@JMyers56

I spoke to Julie at Insights and considering your customization levels, it sounds like it will make your lives easier!!!

Mark W.

P.S. My favorite Kenosha restaurant is Redirecting.... My son’s a senior at Carthage.