Problem with third party dll, and application shut down - help!

J

James Radke

Hello,

I am using some external functions supplied by an ERP vendor in a
windows.forms application (vb.net, visual studio.net 2003)

The functions are defined as follows:

' Max startup and shutdown functions
Declare Function InitMAXOrder Lib "MAXORDR2.DLL" (ByRef DataPath As
StringBuilder, ByRef MAXPath As StringBuilder) As Integer
Declare Function ShutdownMAXOrder Lib "MAXORDR2.DLL" (ByVal ObjectHandle
As Integer) As Short

If I never execute the functions, everything works fine....

Once I execute the initialization and shutdown however, the application
closed fine, but the process is still running when I look in Task Manager.

If I use a process.GetCurrentProcess.kill statement, which I assume forces
everything out of memory, the process is stopped.

My question is: Is there a more gracefull way to close down whatever
resource is being held, without using the process kill command? And, if I
have to use a process kill command, is there a way to set a return code to
be returned from the application?

Thanks!

Jim
 
H

Herfried K. Wagner [MVP]

James,

* "James Radke said:
I am using some external functions supplied by an ERP vendor in a
windows.forms application (vb.net, visual studio.net 2003)

The functions are defined as follows:

' Max startup and shutdown functions
Declare Function InitMAXOrder Lib "MAXORDR2.DLL" (ByRef DataPath As
StringBuilder, ByRef MAXPath As StringBuilder) As Integer
Declare Function ShutdownMAXOrder Lib "MAXORDR2.DLL" (ByVal ObjectHandle
As Integer) As Short

If I never execute the functions, everything works fine....

Once I execute the initialization and shutdown however, the application
closed fine, but the process is still running when I look in Task Manager.

If I use a process.GetCurrentProcess.kill statement, which I assume forces
everything out of memory, the process is stopped.

What does the manufacturer write about this problem? Are you sure you
are using the functions properly?
 
J

James Radke

The manufacturer has the worst technical support I have ever run across.
They have not been able to answer any questions posed to them.

And, yes, I followed their sample application (written in VB6) and am using
the routines exactly the same way that they used them.

When I use a monitor to check the remaining process in memory, it looks like
it has a thread that is somehow related to the NTDLL.DLL - whatever that
is.... then if I shutdown that thread, the process stops....... Does that
help?

Jim
 
C

CJ Taylor

Hello,
I am using some external functions supplied by an ERP vendor in a
windows.forms application (vb.net, visual studio.net 2003)

The functions are defined as follows:

' Max startup and shutdown functions
Declare Function InitMAXOrder Lib "MAXORDR2.DLL" (ByRef DataPath As
StringBuilder, ByRef MAXPath As StringBuilder) As Integer

Does it really call for a StringBuilder to be passed to a regular DLL?
Isn't this a Managed type only?
 
P

Peter Huang

Hi James,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you are using P/Invoke to consume
an third-party product in VB.NET which works in VB6, and the process will
not terminate after you close the winform application.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

' Max startup and shutdown functions
Declare Function InitMAXOrder Lib "MAXORDR2.DLL" (ByRef DataPath As
StringBuilder, ByRef MAXPath As StringBuilder) As Integer
Declare Function ShutdownMAXOrder Lib "MAXORDR2.DLL" (ByVal ObjectHandle
As Integer) As Short

When you close the winform application, you observe the still running
process, what is its CPU consuming, zero or high CPU utilization. Also it
seems that you when you call the ShutdownMAXOrder, you will pass a handle
to the function, I guess it should be an ObjectHandle which is need to be
terminated by the ShutdownMAXOrder inside the DLL, so you may need to
check if the value is the same as the value you get the handle, and check
the Marshal.GetLastWin32Error to check if there is any error.
Marshal.GetLastWin32Error Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemRuntimeInteropServicesMarshalClassGetLastWin32ErrorTopic.asp


Also you may try to simplify the sample which works in VB6.( e.g. just call
the InitMAXOrder and ShutdownMAXOrder) and use the Visual Basic .NET
Upgrate Wizard to upgrate the vb6 project vb.net to see if the problem
persists.

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi James,

Have you tried my suggestion?
I look forward to hearing from you.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top