question

Chien_yu C avatar image
0 Likes"
Chien_yu C asked Ryan Clark commented

Global table inside a DLL

I have developed a dll from DLLMaker. One of the function directly manipulate a global table. The data is populated correctly and I can use the table in a model. However, when I close/new model, flexsim is just hung (Not responding). I tried to attach the process to a debugger but that does not give me any info since it's not crashing. Please advise how to debug this problem. thanks

FlexSim 20.2.3
global tabledll maker
· 7
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·
Are you able to first disconnect the dll and close FlexSim normally without it hanging?
0 Likes 0 ·
Chien_yu C avatar image Chien_yu C Jason Lightfoot ♦ commented ·

Is there a way to unload the library? My dll function is called by specifying a dll function. I can quit FlexSim normally after loading that function, just not close/new model. I am using something like:

```
treenode truckListTable = reftable("TruckList");

nodeinsertinto(truckListTable);

setnodename(last(truckListTable), it->model);

```

to populate the table. I did not use the Table constructor since this constructor is not in the DllMaker.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Chien_yu C commented ·
File->System->Disconnect DLLs
0 Likes 0 ·
Show more comments
Chien_yu C avatar image Chien_yu C commented ·

The hanging came from one of the com object I am using needs

CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

For all of the exported c function, I have this line as the first line executed before using a static object containing this com object. However, the destructor for that static object would not be able to run in this environment. I can create a user command to clean the com object, but I don't see a trigger for model closed though.

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Chien_yu C commented ·
CoInitializeEx() is only supposed to be called once per thread that needs it. If you have a single static instance of a class, and that class needs COM calls, then consider calling CoInitializeEx() in the constructor of that class, and call CoUninitialize() in the destructor. Does that help, or change anything?
0 Likes 0 ·
Ryan Clark avatar image Ryan Clark commented ·

Hi @Chien_yu C,

We haven't heard back from you. Were you able to solve your problem? If so, please add and accept an answer to let others know the solution. Or please respond to the previous comment so that we can continue to help you.

If we don't hear back in the next 3 business days, we'll assume you were able to solve your problem and we'll close this case in our tracker. You can always comment back at any time to reopen your question, or you can contact your local FlexSim distributor for phone or email help.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.