Webservice crash calling codeunit.

Hi,

I have developed a very simple .NET app that call a webservice in NAV. The codeunit it calls imports sales orders from bespoke buffer header and detail lines. I have a SQL package that populates the buffer tables and then executes the NAVimport.exe. This works fine every time when I’m processing 1 or 2 orders in the buffers tables but when I add many more I get the following error when executing the .exe at the command prompt. Note also that if I run the codeunit in NAV it does not crash with any errors so it’s only when running the .exe with buffer table containing many new orders.

Here is the error.

Unhandled Exception: System.Web.Services.Protocols.SoapException: Codeunit.Run is allowed in write transactions only if the return value is not used. For example, ‘OK := Codeunit.Run()’ is not allowed.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at NAVOrderImport.WebService.SalesIntegrator.Integrate(String input)
at NAVOrderImport.Program.Main(String[] args)

This is the more detailed error when running from VS 2008

System.Web.Services.Protocols.SoapException was unhandled

Message=“Codeunit.Run is allowed in write transactions only if the return value is not used. For example, ‘OK := Codeunit.Run()’ is not allowed.”

Source=“System.Web.Services”

Actor=""

Lang=“en-GB”

Node=""

Role=""

StackTrace:

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

at NAVOrderImport.WebService.SalesIntegrator.Integrate(String input) in C:\Documents and Settings\crmadmin\My Documents\Visual Studio 2008\Projects\NAVOrderImport\NAVOrderImport\Web References\WebService\Reference.cs:line 79

at NAVOrderImport.Program.Main(String[] args) in C:\Documents and Settings\crmadmin\My Documents\Visual Studio 2008\Projects\NAVOrderImport\NAVOrderImport\Program.cs:line 35

at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

InnerException: