I need to use the axcom.dll in a c# application. Can anyone show me a little axample example?
Hi Ghidini, I’m figuring out the same stuff right now I tried attaching some files for you to check out, but this forum is screwy… Assuming you have set up your business connector and the component is running, within .Net you need to add the com as a project reference (right click on the ‘References’ icon in your project and select ‘Add Reference’. Go to the COM tab, and browse to where AxCom.dll is and open it). As far as code goes, it’s dead easy! //Import the Axapta COM namespace using AxaptaCOMConnector; /* Log in. Leaving the params blank causes the app to login using the current default on the machine hosting the ABC. Also, the only way to safely determine success or failure is with a try/catch on System.Runtime.InteropServices.COMException / Axapta axCOM = new Axapta(); axCOM.Logon("", “”, “”, “”); / Assuming successful login, instantiate an object. Note that the output param specified in the Dev docs should be omitted, it is the return value / IAxaptaObject tstObj; tstObj = axCOM.CreateObject(“COMTestClass_MB”, null, null, null, null, null, null); / Do something with the object */ string tstStr; tstStr = (string) tstObj.Call(“getString”, null, null, null, null, null, null); System.Console.WriteLine(tstStr); //Finally, log out axCOM.Logoff(); For comprehensive documentation on the available COM functionality, look in the Developers Guide under Axapta Business Connector->Reference Documentation. Good luck
Hi sunax, thanks for your replay… After my posting i played a bit with the connector and i’m now able to login execute a query and an insert into the db… Every time i close an application I have the following error: Runtime error! R6025 - Pure virtual function call Any suggestion? And how about getting the hresult return code of the com’s methods? the visual studio wrapper Interop.AxaptaCOMConnector.dll shows me a lot of void methods (like logon) so i lose the result informations. Any suggestion again? (And sorry for my english!) (And thanks!)