2

I have the absurd situation (don't blame me, it is third party software) where I need to have two references (Erp.Contracts.BO.Quote and Erp.Contracts.BO.SalesOrder), but the type Erp.Tablesets.QuoteQtyRow is defined in both assemblies!

How do I use them in code?

void Absurdity()
{
    Erp.Tablesets.QuoteQtyRow qqr_Quote = null; //<-- my intention is to use the one from the quote assembly here.
    Erp.Tablesets.QuoteQtyRow qqr_SO = null; //<-- my intention is to use the one from the sales order assembly here.
}

The compiler throws an error. Namely: "The type 'Erp.Tablesets.QuoteQtyRow' exists in both assemblies."

EDIT: LIMITATIONS:

  1. I do not have the flexibility of using an extern alias as provided in this answer Class with same name in two assemblies (intentionally). I am limited by the environment supplied by the third party software. I essentially need a way to make the distinction within the body of a method.

  2. I understand I can avoid this problem altogether by using the dynamic keyword, but I am looking for a possible strongly typed solution.

  3. There may not be a solution, but I want to exhaust all my resources before I give up on the problem.

Community
  • 1
  • 1
Price Jones
  • 1,948
  • 1
  • 24
  • 40
  • https://www.bing.com/search?q=c%23+same+type+two+assembly – Alexei Levenkov Jan 19 '17 at 16:17
  • @AlexeiLevenkov I know what a namespace is and how to use bing. Could you offer anything more specific? – Price Jones Jan 19 '17 at 16:45
  • Please [edit] post so it is clear what restrictions are so post can be re-opened (and possibly answered by someone). Side note: post should *demonstrate* what research you've already done - just the fact you can use search engines does not mean much for SO post itself. – Alexei Levenkov Jan 19 '17 at 17:02

1 Answers1

2

Epicor ERP uses a tool to put together tables from the DB into datasets, and then on into Business objects. This business object is described in the contract assembly, but as you have found when you use two business object that references the same table you run into problems. This is more commonly an issue with the SerialNumber tables.

I understand from your notes that you are providing method body code in a Method Directive or data Directive within the Epicor ERP application. This is entered on the client and stored in the database but generates code on the server in the Deployment\Server\BPM\Sources\BO folder and is compiled to the Deployment\Server\Customization\BO folder.

There is no way to specify an alias for the referenced DLL in the "Execute Custom Code" workflow item of the BPM designer. The fix is requested in SCR 148549. There is no project file for you to edit, and even if there was every time the BPM was enabled and disabled it would be regenerated.

However, if you use the "Invoke External Method" workflow item, then you can build your own dll and put it in the Deployment\Server\Customization\Externals folder. To do that:

  • Click Actions > Create Programming Interfaces for your method in Method Directive Maintenance for your BPM and copy the code.
  • Create a new Class library project in Visual Studio
  • Paste the copied code into the .cs file
  • Add Assemblies - Framework references:
    • System.Data.Entity
    • System.ServiceModel
    • System.Transactions
  • Add file references to
    • Bin\Epicor.ServiceModel.dll
    • Assemblies\Epicor.Ice.dll
    • Assemblies\Epicor.System.dll
    • Assemblies\Ice.Data.Model.dll
    • Assemblies\Erp.Data.910100.dll
  • And add a reference for the BPM's BO i.e.
    • Assemblies\Erp.Contracts.BO.Quote.dll
  • Ensure all the references have Copy Local set to false.
  • Inherit from Ice.ContextBoundBase<Erp.ErpContext>
  • Add a constructor that takes a context public MyQuote (Erp.ErpContext ctx) : base(ctx){ }

You can't quite copy and paste the "Execute Custom Code" body in as you won't have access to the tt row variables, these are all in the ds.

Stephen Turner
  • 7,125
  • 4
  • 51
  • 68