error code 126

This widget could not be displayed.

error code 126

Anonymous
Not applicable

I am creating my own plugin using other some dlls.

It reports error code 126, can't find the specificated module.

 

Where to find more detailed debug information, for example, the missing module's name?

0 Likes
Reply
Accepted solutions (1)
15,234 Views
10 Replies
Replies (10)

cyrille
Alumni
Alumni
Accepted solution

Hi

 

You probably having a DLL search path problem int he best case, and a DLL hell issue in the worse case. The error comesfrom LoadLibrary() and LoadLibrary would fail if it cannot find the DLL or one of its dependencies with the right version usually.

 

To solve the problem, I would

1- verify that the search path is set properly,

2- use the dependency walker tool to look for any obvious problems to find a dependencies,

3- use the sysinternals utility Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645 from Microsoft to trace all file access while your dll is trying to load. With this utility, you will see everything that that dll is trying to pull in and usually the problem can be determined from there.

 

In the wose case, the system find the dependencies, but not the right version. What I mean is that it may find an older (or newer) version than the one you need in the search path, and before the one you expect. And that will cause the DLL or the root plugin to fail loading.

 

Hope that helps,

 

Anonymous
Not applicable

Hello. I've got the same error in case of linking my plugin with external dlls in same folder. Looks like 3ds max cannot find these dlls in same plugin folder. 

 

0 Likes

bdenhartog
Explorer
Explorer

Hi all,
I have the strange situation, that my plugin is correctly loaded the first time I start 3dsmax. However, if I close down 3dsmax and start it up again, then I get (and keep on getting) the 126 error. 
This only happens with max2018, and later versions don't have this issue. 

If it would happen every time, then I could understand it. But it works the first time, and fails the second/third/... time.

Does anyone have a clue?
Thanks!

0 Likes

istan
Advisor
Advisor

I'd do what Cyrille was writing in his reply..

0 Likes

bdenhartog
Explorer
Explorer

I know. I've tried that already 😉 , but unfortunately couldn't find anything useful. 
If I had found something, then this still doesn't explain the loading issue. Because that would mean the loading should fail every time. And in my case, it is only the first time in which it loads correctly. After that, it fails continuously.
And it is only a 2018 problem. Because I also build the plugin for max2019 and up. And there this problem doesn't occur at all. 


0 Likes

istan
Advisor
Advisor

Which kind of plugin is it? C++? What did Procmon report? Which dll(s) is(are) missing ?

0 Likes

bdenhartog
Explorer
Explorer

C++

The same plugin is build against max2019 sdk and 2020 sdk and there we don't have any issues. 
When I load 2018 the first time, I don't get the error message. The times after that, it does. This is structurally the same. Which I find strange, because if there is a dependency issue, this should also be the case the first time. (I guess 😉 )

I attached a screenshot from dependency walker.

0 Likes

denisT.MaxDoctor
Advisor
Advisor

Could you show the DLL which cannot be loaded first? It is in the bottom list of Dependency Walker

0 Likes

bdenhartog
Explorer
Explorer

Gentlemen, thanks for the response.
I have fixed the issue.  🙂 
After trying many things, I came across a webpage
https://area.autodesk.com/blogs/max-station/n88_if_you_can_run_3ds_max_only_once/
In which they refererred to another page:

http://download.autodesk.com/global/docs/3dsmaxsdk2012/en_us/index.html?url=files/GUID-0C178DAC-7F0C...
There they also describe a 126 error:
---

Load Order Dependencies between Plug-ins

The deferred plug-in DLLs are loaded when a certain user action requires them to be present. Because the sequence of user actions is not always predictable, the order in which deferred plug-in DLLs are loaded by 3ds Max will not be deterministic. In general, Plug-in DLL A has a load order dependency on plug-in DLL B if B needs to be loaded in 3ds Max's address space before A. If plug-in DLL A calls a function exported from plug-in DLL B, a load order dependency will exist between the two plug-in DLLs.

If the plug-in DLL B is defer loaded:

 

Plug-in DLL A may fail to be loaded by the operating system's loader. In thiscase error 126 (The specified module could not be found) is displayed by the operating system. This is the case if plug-in DLL A links against plug-in DLL B.

  • A run-time error may occur if plug-in DLL A tries to acquire the address of a function exported by plug-in DLL B (with a call to WINAPI GetProcAddress()) and call that function.

 

The solution to this problem is to eliminate the load order dependency between the two plug-in DLLs by:

  • Moving the functionality that the plug-in DLL A (and possibly plug-in DLL B) relies on into a new DLL C that is not a plug-in and that any plug-in DLLs can either link against or load at runtime.
    • The DLL containing the common functionality should not be delay loaded if it exposes core interfaces to MAXScript. The delay loading mechanism may result in the core interface not being properly registered and 3ds Max may crash when client code requests such an interface.
  • Exposing the functionality plug-in DLL A relies on as a core interface (an object that derives from FPStaticInterface and is created with the FP_CORE flag). Plug-in DLLs that expose core interfaces are guaranteed to be loaded on demand, when client code acquires the core interface they expose.

---

 

This led me to check  our 2 plugins. 
Both have this:
--

// The plug-in opts out from 3ds Max’s defer loading mechanism, 
// i.e. it’s always loaded when 3ds Max starts up.
__declspec( dllexport ) ULONG CanAutoDefer()
{
   return FALSE;
}

--

 

However, only one had:

 

--

You will also need to add this line to the *.DEF file. Example:

 CanAutoDefer @5

--


The plugin that did not have this line in the *.def file was not the plugin that failed to load though... But when I corrected this, and added the given line to that plugin so they are both the same. The problem was gone! So apparently max2018 does something different wrt the loading of plugins than max2020 and up. 

0 Likes

bubo3d
Explorer
Explorer

just uninstall and reinstall the last version that you downloaded it

0 Likes