By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,318 Members | 2,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,318 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
James,

* "James Radke" <jr*****@wi.rr.com> scripsit:
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?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
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
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c1*************@ID-208219.news.uni-berlin.de...
James,

* "James Radke" <jr*****@wi.rr.com> scripsit:
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?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3

P: n/a
> 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?

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

Nov 20 '05 #4

P: n/a
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/de...us/cpref/html/
frlrfSystemRuntimeInteropServicesMarshalClassGetLa stWin32ErrorTopic.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.

Nov 20 '05 #5

P: n/a
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.

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.