Unable to find assembly for contract 'Erp.Contracts.QuoteSvcContract'

Does anyone know if I’m actually missing an assembly or is there something else I need to instantiate?

I’m setting up Visual Studio tests to instantiate an ErpContext object and run through some code that adds/updates quote details. However, I keep getting the error "Unable to find assembly for contract “Erp.Contracts.QuoteSvcContract” after attempting to create a quote service (shown below):

ErpContext context = new ErpContext();

Erp.Contracts.QuoteSvcContract quote = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.QuoteSvcContract>(context);

The context is created without any errors and the error occurs when attempting the GetService call on the quote.

Here are my current project references:
image

Thanks,

Josh

Hi Josh,

New to Epicor and C#, but I’m going to take a stab at answering this (bear with me please).

It is possible to search for an adapter or assembly in customization mode by going to tools > assembly references > add custom reference – and then searching for the assembly you’re looking for in the Epicor folder. I just did a search on my PC and did not find that reference. Not sure exactly what you’re going to use this code to do, but it might be possible to add or update a quote detail by referencing an adapter. These can be found in customization mode under tools > object explorer > adapters.

Hope this helps.

Hi Josh,

Did you ever get to the root of your problem?

I am having the same issue when trying to run:
svcSalesOrder = Ice.Assemblies.ServiceRenderer.GetService(Db);

Error: Unable to Find Assembly for Contract ‘Erp.Contracts.SalesOrderSvcContract’.

I have referenced the Erp.Contracts.BO.SalesOrder.

Any help would be appreciated.

Thanks,
Dan

If you’re passing in the db context, try something like this…

Erp.Contracts.SalesOrderSvcContract salesOrder = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db, false);

Thanks Josh.

I tried that earlier but it had no effect. :frowning:

It’s an odd error, I’m pretty sure i’ve referenced everything correctly!

Are you passing in the Db context or trying to instantiate a new Db context via code?

Im trying to instantiate a new Db.
My code is below:

//Arrange
            InitialiseConfiguration(webConfigFile);
            Db = new Erp.ErpContext();
            int result;
            MethodDirectives jo = new MethodDirectives(Db);

            //Act
            using (var session = new Ice.Core.Session(
                "<Username>",
                "<Password>",
                null,
                Ice.Core.Session.LicenseType.Default,
                @"C:\Epicor\ERP10.1.400.29Client\Client\Config\EpicorERPUAT2.sysconfig", false, "<COMPANY>"))
            {

                Erp.Contracts.SalesOrderSvcContract salesOrder = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db, false);

                //Set up Tableset
                Erp.Tablesets.SalesOrderTableset so = new Erp.Tablesets.SalesOrderTableset();
                so = salesOrder.GetByID(OrderNum);
                
                //Set Up function variables
                bool lCheckForOrderChangedMsg = true;
                bool lcheckForResponse = true;
                string cTableName = "OrderRel";
                int iCustNum = so.OrderHed[0].CustNum;
                int iOrderNum = so.OrderHed[0].OrderNum;
                bool lweLicensed = true;
                bool lContinue = false;
                string cResponseMsg = "";
                string cCreditShipAction = "";
                string cDisplayMsg = "";
                string cCompliantMsg = "";
                string cResponseMsgOrdRel = "";


                result = jo.ProcessJobActions(ref lCheckForOrderChangedMsg, ref lcheckForResponse, ref cTableName, ref iCustNum, ref iOrderNum, ref lweLicensed,
                                              ref lContinue, ref cResponseMsg, ref cCreditShipAction, ref cDisplayMsg, ref cCompliantMsg, ref cResponseMsgOrdRel, so);

            }

            //Assert 
            Assert.AreEqual(116247, result);

I’m not sure how/what Epicor is doing when they instantiate the Db object, but I’ve always received the same error message when trying to instantiate my own Db context. However, if the Db context is passed into your code from Epicor, it works fine.

As an alternative, I was able to get a proxy object to work in the similar way…

Ice.Core.Session session = new Ice.Core.Session(userID, password, Ice.Core.Session.LicenseType.EnterpriseProcessing, @“C:\Epicor\DevTech\Client\config\DevEnvironment.sysconfig”);

Erp.Proxy.BO.SalesOrderImpl order = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.SalesOrderImpl>(session, Erp.Proxy.BO.SalesOrderImpl.UriPath);

The proxy is a valid way to go I think.

The only reason I didn’t want to go that way, is because I need to pass in to my function a TableSet not a DataSet. Short of instantiating a TableSet and filling it in, do you know of anyway to convert a Dataset in to a TableSet?

This will return you the Epicor specific dataset based on the order number…

Erp.BO.SalesOrderDataSet salesOrderTableset = order.GetByID(orderNum);

What are you trying to convert?

I have that already and your correct it gets the data.

What i want to do ultimately is pass an Erp.TableSets.SalesOrderTableset to a BPM function.

public int ProcessJobActions(
            ref System.Boolean lCheckForOrderChangedMsg,
            ref System.Boolean lcheckForResponse,
            ref System.String cTableName,
            ref System.Int32 iCustNum,
            ref System.Int32 iOrderNum,
            ref System.Boolean lweLicensed,
            ref System.Boolean lContinue,
            ref System.String cResponseMsg,
            ref System.String cCreditShipAction,
            ref System.String cDisplayMsg,
            ref System.String cCompliantMsg,
            ref System.String cResponseMsgOrdRel,
            Erp.Tablesets.SalesOrderTableset ds
            )

So essentially, what i need to do is convert the Erp.BO.SalesOrderDataSet to Erp.TableSets.SalesOrderTableset (if it is possible). I have read that there is a helper class that can do the conversion in the Epicor.ServiceModel but i cant find it.

Do you know what DLL/namespace the Erp.TableSets.SalesOrderTableset belongs to? I don’t see an Erp.TableSets dependency.

Sorry, I should have explained myself more.
ProcessJobActions is a custom function in an external DLL that I am writing.

I am creating a BPM to automatically create jobs (under various criteria) when MasterUpdate is triggered in Order Entry. The method above is using the same method signature as MasterUpdate which takes in as a parameter Erp.TableSets.SalesOrderTableset.

That is where the dependancy is coming from.

You can try serializing the dataset and then deserialize the dataset into the tableset…

Erp.Tablesets.SalesOrderTableset salesorderTS = JsonConvert.DeserializeObject<Erp.Tablesets.SalesOrderTableset>(JsonConvert.SerializeObject(salesOrderDataSet));

Since both objects appear to have the same properties, it should work.