Launch custom dll

Hi all,

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

C#

	private void btnEmail_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		EpiDataView edvVarName = (EpiDataView)(oTrans.EpiDataViews["InvcGrp"]);
		String GroupID = Convert.ToString(edvVarName.dataView[edvVarName.Row]["GroupID"]);
		EpicorDll.clsInvoice.LoadInvoiceForm(GroupID,ARInvoiceForm.Session);
	}

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’

I would appreciate any pointers anyone may have?

Thank you.

I think you’re passing the wrong session object. Pass the actual Ice.Core.Session, not the form session object

The button that is used to launch the form is on the ARInvoiceForm. I have tried replacing as suggested but that didn’t work either.

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

Thanks @Aaron_Moreng

I tried as mentioned (code below)

private void btnEmail_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
EpiDataView edvVarName = (EpiDataView)(oTrans.EpiDataViews[“InvcGrp”]);
String GroupID = Convert.ToString(edvVarName.dataView[edvVarName.Row][“GroupID”]);
EpicorDll.clsInvoice.LoadInvoiceForm(GroupID,ref Ice.Core.Session);
}

However, I am still getting an error (below)

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

Error: CS0119 - line 74 (671) - ‘Ice.Core.Session’ is a ‘type’, which is not valid in the given context

** Compile Failed. **

I’m a little out of my depth so any suggestions greatly appreciated.

Thank you

Michael

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)
image

Hi @Aaron_Moreng that’s all working now thanks and will help me resolving other customizations moving forward.

private void btnEmail_Click(object sender, System.EventArgs args)
{
	// ** Place Event Handling Code Here **
		
		EpiDataView edvVarName = (EpiDataView)(oTrans.EpiDataViews["InvcGrp"]);
		String GroupID = Convert.ToString(edvVarName.dataView[edvVarName.Row]["GroupID"]);
		var session = oTrans.CoreSession;
		EpicorDll.clsInvoice.LoadInvoiceForm(GroupID,ref session);
}