Cancel
Showing results for 
Search instead for 
Did you mean: 

Unload shared Image by .Net C#

Valued Contributor
Valued Contributor

Hi all,

 

Can anyone help me how to write a C# nxopen code to unload shared image.

 

Thanks in advance.

 

Regards,

Yunus

8 REPLIES 8

Re: Unload shared Image by .Net C#

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi @Yunus ,

Try below:

public static int GetUnloadOption(string arg)
    {
       return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately); 
    }

Regards,

Amol 

Re: Unload shared Image by .Net C#

Siemens Phenom Siemens Phenom
Siemens Phenom

See also Unload Option in the NXOpen Programmer's Guide for additional details and to explain that unloading an image is nothing that needs to be done actively.

It happens automatically if NX finds and calls this method with the appropriate return value.

The Visual Studio NXOpen wizards also add this method to the template code.

Re: Unload shared Image by .Net C#

Valued Contributor
Valued Contributor

Hi @AmolKadam ,

 

It is not working. I shall explain a bit more.
I have created one .dll file to find number of curves in a model file. Once after I run .dll file in the model file and after if I try to do modifications in the code in visual studio and trying to re-build .dll file getting an error.

If I navigate to,

File --> Utilities -->  Unload Shared Image

and click on Unload All.

After that if I go to visual studio and re-build it is successfull.

 

Hope you got me. Let me know if you have any clarifications.

 

Regards,

Yunus M

 

 

Re: Unload shared Image by .Net C#

Hi @Yunus 

In your original program include  a fuction

 

Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
        'Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
        Return CType(Session.LibraryUnloadOption.Immediately, Integer)
        ' Return CType(Session.LibraryUnloadOption.AtTermination, Integer)
    End Function

and rebuild it.

 

Frank Swinkels

Re: Unload shared Image by .Net C#

Creator
Creator
You have to put this function where your static "Main" method is, otherwise it won't work.

Re: Unload shared Image by .Net C#

Valued Contributor
Valued Contributor

Hi @FrankSwinks1 & @essigwurst ,

 

I have added these codes but still it is not working.

 

Thanks,

Yunus M

Re: Unload shared Image by .Net C#

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Note there are certain things in API that, if you have them in your code, prevent the API program from being unloaded.

I believe there is documentation somewhere, but things like registering a callback typically cause this issue.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled


Re: Unload shared Image by .Net C#

Siemens Phenom Siemens Phenom
Siemens Phenom

> You have to put this function where your static "Main" method is

 

The GetUnloadOption function has to be in the same assembly (DLL or EXE) as your Main function. Some people say that these two functions need to be in the same class, but this is not true.

 

You could (temporarily) comment out all the code in your Main function, and see if unloading then works correctly. If it does, then something in your Main function is blocking unloading, as KenA suggested.

 

If you post your code, you have a much better chance of getting a good answer.

山田
yamada