Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

error code 126

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Anonymous
15234 Views, 10 Replies

error code 126

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?

10 REPLIES 10
Message 2 of 11
cyrille
in reply to: Anonymous

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,

 

Message 3 of 11
Anonymous
in reply to: cyrille

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. 

 

Message 4 of 11
bdenhartog
in reply to: Anonymous

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!

Message 5 of 11
istan
in reply to: bdenhartog

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

Message 6 of 11
bdenhartog
in reply to: istan

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. 


Tags (1)
Message 7 of 11
istan
in reply to: bdenhartog

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

Message 8 of 11
bdenhartog
in reply to: istan

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.

Message 9 of 11

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

Message 10 of 11

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. 

Message 11 of 11
bubo3d
in reply to: Anonymous

just uninstall and reinstall the last version that you downloaded it

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report