I have a system where some customizations launch a form within a custom dll and the code is written in VB. I am with limited knowledge trying to change this code to C# but am generating an error within the code and was hoping someone can give me some pointers. The VB Code is below. How do I launch the form using C#
VB
Private Sub btnEmail_Click(ByVal sender As Object, ByVal args As System.EventArgs)
' ** Place Event Handling Code Here **
Dim edvVarName As EpiDataView = CType(oTrans.EpiDataViews("InvcGrp"), EpiDataView)
Dim GroupID As String = edvVarName.dataView(edvVarName.Row)("GroupID")
EpicorDll.clsInvoice.LoadInvoiceForm(GroupID,ArInvoiceForm.Session)
End Sub
All compiles okay except for the last line which gives the following errors
Error: CS1502 - line 74 (671) - The best overloaded method match for ‘EpicorDll.clsInvoice.LoadInvoiceForm(string, ref Ice.Core.Session)’ has some invalid arguments
Error: CS1503 - line 74 (671) - Argument 2: cannot convert from ‘object’ to ‘ref Ice.Core.Session’
Your error is definitely relating to the object type, and it’s saying that it’s expecting the session type I described.
There are different session objects in the form and the one it’s looking for is the one you’re not passing it. You also need to include the ref keyword on the second object
It’s hard to say with a lot of authority, because you are calling a custom library and that would be impossible to guess what the issue exactly is.
But from the error, the method you are calling is expecting a string and then a reference to Ice.Core.Session.
In the first example, you were passing it the ARInvoiceForm.Session object (not by ref, so you might try adding that).
The other thing I’d try is passing it the oTrans.CoreSession object in the ARInvoiceForm
Sample code (imagine that the YourLib method is your custom DLL’s method signature, and the Test method is you calling the YourLib method from your code)