Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX12 Preventing me from recompiling VB.NET NXOpen .exe

Status
Not open for further replies.

AeroAutomation

Mechanical
Jul 18, 2020
2
I wrote my first simple .exe file using VB.NET using NXOpen and it successfully compiles and runs but after running the .exe file for the first time i cannot modify it and compile it again because the file is "being used by another process" or "locked by NX"

note: I called my exe file "NX.exe" which in hindsight is probably a very confusing name. sorry....

is there a way to get NX to release the .exe file and all the relevant dll files so I don't have to close NX every time I want to recompile?

my visual studio solution only consists of a single project which compiles into an exe file. I would like to eventually break up my code into several dll files + 1 main exe file for code organization reasons.

here is the exact error message from Visual Studio 2019:

1>------ Rebuild All started: Project: NX, Configuration: Debug x64 ------
1>warning MSB3061: Unable to delete file "C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NX.exe". The process cannot access the file 'C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NX.exe' because it is [highlight #FCE94F]being used by another process[/highlight].
1>warning MSB3061: Unable to delete file "C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NXOpen.dll". Access to the path 'C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NXOpen.dll' is denied.
1>warning MSB3061: Unable to delete file "C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NXOpen.Utilities.dll". Access to the path 'C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NXOpen.Utilities.dll' is denied.
1>warning MSB3061: Unable to delete file "C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NXOpenUI.dll". Access to the path 'C:\Users\Me\source\repos\NX\NX\bin\x64\Debug\NXOpenUI.dll' is denied.
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 1 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. [highlight #FCE94F]The file is locked by: "NX 12 (12208)"[/highlight]
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 2 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 3 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 4 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 5 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 6 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 7 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 8 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 9 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>warning MSB3026: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Beginning retry 10 in 1000ms. The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process. The file is locked by: "NX 12 (12208)"
1>error MSB3027: Could not copy "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". Exceeded retry count of 10. Failed. The file is locked by: "NX 12 (12208)"
1>error MSB3021: Unable to copy file "obj\x64\Debug\NX.exe" to "bin\x64\Debug\NX.exe". The process cannot access the file 'bin\x64\Debug\NX.exe' because it is being used by another process.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
 
Replies continue below

Recommended for you

i found the solution in an online PDF. here is the relevant section.

A project based on the Class Library template has another deficiency — it doesn’t include a GetUnloadOption
function. This means that NX won’t know how to “unload” your code after it has finished executing — in some
sense, NX “holds onto” your code, and won’t let it go. So, if you try to change your code and rebuild the project,
you’ll get an error message telling you that you “can’t access the file because it is being used by another process”.
The other process is NX, and you’ll have to terminate NX to get it to release its hold on your DLL so that you can
rebuild it. The NX Open Application Template provides a GetUnloadOption function for you, so you won’t have
these sorts of problems. Writing your own GetUnloadOption function is fairly simple. The code is as follows:

Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
Return CType(NXOpen.Session.LibraryUnloadOption.Immediately, Integer)
End Function

It’s convenient to place this code in the same class or module as your “Main” function — in our case, this means
inside the NXOpenSample class that we created. So, you just need to paste this code immediately before the line that
says “End Class”. Please look up GetUnloadOption in the NX Open Programmer’s Guide for more information about
unloading code
 
You can also use File/Utilities/Unload Shared Image from NX to release the file.

Mike Hyde
NX12.0.0 with TC11.3 and Vis 11.3
Working on upgrade to NX1872, TC12.2 and Vis 12.2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor