VB.Net API application from E9 to E10

I have a “programmer” who had this working for E905.603: (I don’t know why some of these import statements are here)

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Linq
Imports System.Text
Imports Epicor.Mfg.Core
Imports Epicor.Mfg.BO
Imports System.Data.SqlClient
Imports Epicor.Mfg.IF

Module Module1

Sub Main(ByVal cmdArgs() As String)
Dim QNum as integer
Using epiSession As New Epicor.Mfg.Core.Session(“xxxxUser”, “xxxxPassword”, “AppServerDC://EPICOR:9401”, Session.LicenseType.Default) '9401 is epicor905
Dim custBO As Quote
custBO = New Quote(epiSession.ConnectionPool)
Dim cds As New QuoteDataSet
cds.QuoteHed.Rows(0)(“CustomerCustID”) = CustID
QNUM = cds.QuoteHed.Rows(0)(“QuoteNum”)
End Using
End Sub

End Module

What do we need to change to get it working in E10.1.18.400? He has tried many different ways to make the connection but fails consistently and I’m worn out googling this. WCF? Any examples of using an adapter via external application you can share?

Completely lost,

Jeff there are many examples on how to invoke the BO’s / Adapters in the forum. Do some searching and you should find quite a few.
I recommend you convert your customization to C# in 10 since VB is not supported in some of the platform (web)

1 Like

The connection is different in 9 to 10. Something like this should work.

EpiSession = New Session(MyUser, MyPassword, “”, Ice.Core.Session.LicenseType.Default, _
“C:\Epicor\ERP10.1Client\Client\Config” & MyDatabase & “.sysconfig”, _
False, “COMPANY”, MySite)

Jose, We are planning on converting to C#. We do not have time right now and everything we use VB.net for is working in E10.1.400.18. It does not work for E10.1.500+. We will sit on 400.18 until we have everything converted. I do not see any examples of connecting to E10 from an external source to an adapter. I have searched the forum. Perhaps I need a forum search class. :slight_smile:

Matt, We will try that. If I remember correctly, my programmer said when he holds the mouse over the New Session code in Visual Basic Studio, it does not show that many parameters. We will take a closer look.

I’m also confused on the Imports statements required. If we are connecting to the QuoteEntry adapter, should copying the Imports statements from a base Quote Entry customization be all we need? Or is there another way to find what we need?

1 Like

I misunderstood didn’t realize it was an external program. For this you can use various methods
WCF Services Directly
REST Services
or DLL’s which already implement the WCF Services

Here’s how to use REST

Here’s how to use WCF Services

Here is how to use the DLL’s / WCF Implementations

/* You'll need to reference
    Erp.Contract.BO.Part.dll (or whatever BO you need)
var wcfBinding = NetTcp.UsernameWindowsChannel();
	var appServer = new Uri("net.tcp://localhost/epicor10/erp/bo/part.svc");
	using (var partClient = new PartImpl(wcfBinding, appServer))
		partClient.ClientCredentials.UserName.UserName = "Manager";
		partClient.ClientCredentials.UserName.Password = "Epicor123";
		bool morePages;
		var myPartDataset = partClient.GetList("", 10, 1, out morePages);
		foreach (var partRec in myPartDataset.PartList.Rows.Cast<PartListDataSet.PartListRow>())
1 Like

Anyone know what is causing this error:

We get error "The type initializer for ‘Ice.Core.Session’ threw an exception.”.

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports Ice.Core
Imports Ice.Core.Session
Imports Erp.BO
Imports System.Diagnostics
Imports Microsoft.VisualBasic
Imports Erp.Adapters
Imports Erp.UI
Imports Ice.Lib

Module Module1

Sub Main(ByVal cmdArgs() As String)
    On Error GoTo ErrorHandler
    Dim epiSession = New Ice.Core.Session("Login", "Pwd", "", Ice.Core.Session.LicenseType.Default, "C:\Epicor\ERP10.1Client\Client\config\ERP10.1.sysconfig", False,"DTSF","MfgSys")
    Exit Sub

End Sub

End Module

I’ve got the connection to the EpiSession finally. It is displaying the company id in the text box. Now I’m trying to use the QuoteEntry adapter. What should the EpiSender be?

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = “H1”
Dim QNUM As Integer = 0
Dim CustID As String = “2305”
Dim epiSession = New Ice.Core.Session(“Manager”, “manager”, “”, Ice.Core.Session.LicenseType.Default, “C:\Epicor10\Client\config\ERP10.1.sysconfig”, False, “DTSF”, “MfgSys”)
TextBox1.Text = “CompanyId=” & epiSession.CompanyID

    Dim EpiSender As Object = "What should this be?"
    Dim custBO As Erp.Adapters.QuoteAdapter = New Erp.Adapters.QuoteAdapter(EpiSender)

    If custBO.GetNewQuoteHed() = True Then
        Dim TestStr As String = custBO.QuoteData.QuoteHed.Rows(0)("TerritoryID")
        TextBox1.Text = "TestStr = " & TestStr
        custBO.QuoteData.QuoteHed.Rows(0)("CustomerCustID") = CustID
        QNUM = custBO.QuoteData.QuoteHed.Rows(0)("QuoteNum")
        TextBox1.Text = "False"
    End If
    TextBox1.Text = "QuoteNumber = " & QNUM.ToString()
End Sub

End Class