While NX Part Session is opened, loading application through NX (File >Execute>NX Open) works fine.

What I would like to do is to execute code by double click on the exe or through Visual Studio 2015>Debug.

I have received some errors:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll - Solved by copying all libraries from "C:\Program Files\Siemens\NX 11.0\NXBIN\managed" to debug folder.

An unhandled exception of type 'System.DllNotFoundException' occurred in NXOpen.dllAdditional information: Unable to load DLL 'libpart': The specified module could not be found. (Exception from HRESULT: 0x8007007E) - I have tried to solve by copying "libpart.dll" from C:\Program Files\Siemens\NX 11.0\NXBIN to debug folder. Didn't solve the error .

Re: Debug NX Open code through external exe application

You should execute from a NX command prompt to ensure that all of the necessary env variables are set correctly. If you examine the NX Command prompt shortcut, you will see it does something like this:

An NX Open application .exe file can be executed directly from a command line as any other executable. Since this is a managed application, you will need to do one of the following:

Copy the NX .NET libraries to your local working directory. To do so, copy all of the libraries from the %UGII_BASE_DIR%\ugii\managed directory to your working directory. Use standard operating system command to execute the application.

Tried this way. What I noticed as a difference, specified folder "managed" is not a member of "UGII" directory (C:\Program Files\Siemens\NX 11.0\UGII), but "NXBIN" directory (C:\Program Files\Siemens\NX 11.0\NXBIN\managed). This is by default NX11.0 installation. Please correct me if I am wrong.

Copy your .EXE to UGII_BASE_DIR\ugii\managed. Use standard operating system command to execute the application.

When I run exe by double click or through Visual Studio, NX doesn't start. The NX only starts if I set Start Action of debug mode to Start external program: "C:\Program Files\Siemens\NX 11.0\NXBIN\ugraf.exe"

If you start your external application (eg. by double-click on the exe) you will never start a visible NX session. Your program has its own NX session. You will see nothing (unless your programm has its own GUI). Your sample program just creates a part, creates a point and finishes. If you add a save you will see the resulting part on your file system.

Re: Debug NX Open code through external exe application

When NX session is runned and I have created new part, I start executing my application from Visual Stutio>Debug (or just double click on exe file), I expect that code will be executed and as the result in the currently opened part I expect to see created point (something that my module does). That's it.

Re: Debug NX Open code through external exe application

If you have an external application as created by the wizard you will never be able to connect to a running interactive NX session.

In fact in your case you will have two parallel NX sessions (the interactive one and the one you started with your application). You can find both in the task manager and both sessions have their own syslog file. They have nothing to do with each other.

To debug your external application just set breakpoints and run it from visual studio in debug mode.

If you run your exe from an interactive NX session by Execute/NX Open it is attached as a regular .net dll to your interactive session. In this case it behaves just like an internal application. Debug internal applications by starting ugraf.exe as debug task or attach the debugger to a running ugraf.exe. Then execute your application by Execute/NX Open.

There is a third type of application where an external process communicates with an existing (interactive or non interactive session). Look for 'remoting' in the documentation. But I don't think that is what you want.