Here is an example to call M3 API from .NET in C#.
Background
To call M3 API in .NET there are several options: 1) we can use Interop to wrap the COM unmanaged library, 2) we can use netmodules which were introduced in the M3 API Toolkit version 9.0.1.1, or 3) we can use the native .NET managed library which were introduced in the M3 API Toolkit version 9.0.3.0. I suggest the latter option.
Example
- Download and install the M3 API Toolkit version 9.0.3.0 or later.
- That version includes the .NET library
MvxSockN.dll
:
- You can use .NET Reflector to introspect the assembly:
- That version also includes documentation specifically for .NET:
- That version also includes C# examples:
- If you are using Microsoft Visual C# Express, add a New Reference to the DLL:
- Then add the namespace Lawson.M3.MvxSock to the source code:
using Lawson.M3.MvxSock;
- Then start using MvxSock with IntelliSense:
- Here’s my sample source code:
using System; using Lawson.M3.MvxSock; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { SERVER_ID sid = new SERVER_ID(); uint rc; rc = MvxSock.Connect(ref sid, "hostname", 6800, "userid", "*********", "CRS610MI", null); if (rc != 0) { MvxSock.ShowLastError(ref sid, "Error no " + rc + "\n"); return; } rc = MvxSock.Access(ref sid, "LstByNumber"); if (rc != 0) { MvxSock.ShowLastError(ref sid, "Error no " + rc + "\n"); MvxSock.Close(ref sid); return; } while (MvxSock.More(ref sid)) { Console.WriteLine(MvxSock.GetField(ref sid, "CUNO") + ", " + MvxSock.GetField(ref sid, "CUNM")); MvxSock.Access(ref sid, null); } MvxSock.Close(ref sid); } } }
- Here’s a sample result of calling CRS610MI.LstByNumber:
That’s it!
HI
THX your post!
I want to know different return rc = MvxSock.Access(ref sid, “LstByNumber”); different error msg.
LikeLike
Hi Vincent. I don’t understand your question. But I invite you to read the developer’s guide that’s in the M3 API Toolkit. In the doc folder there’s a PDF that explains everything about the libraries, Java, ActiveX, .NET, etc. There you will get details about the methods, parameters, etc.
LikeLike
THX
I find this one
Code
Explanation
0
OK(no error)
1
General error on input data (user error)
2
No connection to server exists
3
Receive buffer is to small(first part of message from server is returned as valid data)
4
No receive buffer exists
5
Crypto error (internal error. Read plain text for more details)
6
Illegal type of transaction when calling function
7
Other error (severe) (must read plain text message)
11-19
Function specific errors from user input
My M3 API Toolkit is too older can you send it to me the M3 API Toolkit ufo343425185@gmail.com.
Best Regards!!!
LikeLike
Hi Vincent, I cannot send you the API Toolkit as it’s copyrighted material of Infor. However, I can help you find the proper channel. I can also assist you via Infor Services. Send me an email to thib…@infor.com. /Thibaud
LikeLike
Hi!
Is it possible to include the library MvxSockX_SRV.dll in a VB script in SSIS package?
If so, how?
Thanks.
LikeLike
Hi Matthieu, it’s possible to include that library in a VB script, we do that often with Visual Basic for Applications (VBA) in Excel via the VBA via Tools > References. But I don’t know if or how to do it with SSIS. /Thibaud
LikeLike
Hi,
Is it possible to use Single Sign on with the M3 API Toolkit.
Regards,
Yohan
LikeLike
Hi,
We use Windows login to connect to Lawson M3.
Once logged in from LSO users access some customer interfaces which are developed in .net.
Right now we need to pass the credentials to the interfaces.
Is it possible to use Single Sign on (SSO) with the M3 API Toolkit.
Regards,
Yohan
LikeLike
Hi Yohan, I’m sure it’s technically possible, I just don’t know how to implement that. You’re in Windows territory now, not Infor’s. I’m not familiar with Windows authentication, SSO, Kerberos, NTLM, etc. /Thibaud
LikeLike
I created a vb.net application using the MvxSockX_SRV.dll in a .net framework 4 environment. I am getting the error “Attempted to read or write protected memory. This is often an indication that other memory is corrupt” on the MvxSock.Access call. Any suggestions? Thanks.
LikeLike
Hi Steve, use the DLL that has a letter N (for .NET) instead. Here’s some help: https://thibaudatwork.wordpress.com/2012/02/23/how-to-call-m3-api-from-net/
Hope it helps.
/Thibaud
LikeLike
Thanks. I had an old version 9.0.1.0 of the MvxApi. Downloaded a newer version.
LikeLike
Glad it works.
LikeLike
Need to return an unlimited number of rows from a lst api. How would I go about doing that? Right now it’s returning 100.
LikeLike
Hi Matthew, there’s a maxrecs variable, https://thibaudatwork.wordpress.com/2012/02/23/how-to-call-m3-api-with-rest-json/ . For .NET, use MIParameters.MaxReturnedRecords. /Thibaud
LikeLike
Can you please suggest me from where i can download and install the M3 API Toolkit version 9.0.3.0 or later.
LikeLike
Hi Darshita, you can download it from the Infor Xtreme download site by searching for “API Tools”. Otherwise it might already be downloaded in the servers next to your M3. /Thibaud
LikeLike
Hi , I have a problem with the component, returns this message ” Microsoft.SqlServer.Dts.Pipeline.CannotCreateUserComponentException . . Unable to create the class of the user component Make sure your script has a class marked with SSISScriptComponentEntryPointAttribute ”
Thanks for help
Daniel
LikeLike
Bonjour Daniel. I have never seen this error. I suggest you contact Infor Support about it. /Thibaud
LikeLike
Hi Thibaud,
This problem is now solved. But when I run the component, I have this message “Impossible de charger le fichier ou l’assembly ‘Interop.MVXSOCKX_SVRLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ ou une de ses dépendances’
I know that MVXSRVSOCKX_SRVLib is a COM component I am using with .NET code but I already imported System.Runtime.InteropServices which was generally able to make it work.
Regards Daniel
LikeLike
Daniel, I really don’t know. Some basic questions: Are you using the correct DLL for .NET? It should be the filename ending with N for .NET, MvxSockN.dll. Also, did you try the 64bit version, MvxSockNx64.dll, in case you have 64bit Windows? Also, do you have the version of the M3 API Toolkit that matches the M3 BE server?
LikeLike
Check out this other post as well: http://potatoit.kiwi/2010/10/20/apis-%E2%80%93-don%E2%80%99t-forget-to-read-the-fine-print
LikeLike
Hi All,
Can you please mail me that .net DLL file because i have “MvxSockx64.dll” which i can’t able to use on .net as reference.
Can anyone please mail me the .net DLL files on “yogesh.malik@outlook.com”, it’s kinda urgent.
Thanks in advance.
LikeLike
Hi Yogesh, the .NET version of the DLL contains the letter N, MvxSockNx64.dll. Also, we are not allowed to distribute Infor’s proprieaty software. You can download it from the Infor Xtreme downloads website. Otherwise, it’s in every M3 project installation. Otherwise, use the open source alternative from benmat on GitHub.
LikeLike
hi thibaudatwork,
I’ve already register to that site Xtreme downloads, but the site is i think under maintenance and i can’t login to that site.
I know you are not allow to distribute these kind of software, but actually i need that DLL urgent only .net DLL please share me only those .net DLL.
Scenario,
Actually i just want to built and application on .net through which i can upload the data from .net application to INFOR M3 by using M3 program and transaction.
Please help me.
LikeLike
Sorry. Urgency on your part doesn’t change the intellectual property laws. Did you try the open source alternative? Otherwise, to add data to M3 you don’t absolutely need that DLL, you can use the REST endpoint. You don’t need a DLL for that, just HTTP. Have you tried that?
LikeLike
So? Yogesh? Did you try my suggestions? Also, which company/customer is this project for? We can start there. Every customer has the M3 API Toolkit installed on the D: drive of the M3BE and/or MAK servers. Did you check again there?
LikeLike
how to trans api
LikeLike