Referencing a .NET dll using cli/c++ in C++Chop

Hello!
Wondering if anyone has had any success with referencing a .NET dll using /clr in a c++chop. I have the dll I want to use in my list of references in the VS project, and it builds okay. When I bring it into Touch it crashes the .toe file only when the c++ chop uses functions from the linked dlls, not when declaring a variable within that .dlls namespace. I have a working c++ console application that works great, just trying to port it over to Touch is causing issues. Thanks :slight_smile:

Can you give any more details about the function or error you are getting from the crash? What’s the call stack like? I assume it’s some global state with our process but not sure offhand what the issue is.

Okay, been doing more poking around and got more useful looking error. In the main thread it says

“Could not load file or assembly ‘USDSEI’ or one of its dependencies. The system cannot find the file specified.”

USDSEI.dll is one of the dlls I am using. Right now it is sitting in the same folder as the c++ dll that is being called by the c++ chop. Is there another spot it should be located? When it builds it copies the dlls to the release folder which makes me think it is linked properly, but I could also be missing something.

I only change the .dll search path to include that directory when I first load the .dll. Afterwards it won’t look in that dir for dlls. Are you able to do something that causes the .dll to be loaded at the same time as the root .dll, rather than when you first call a function in it? Are you using DELAYLOAD when linking?

Problem fixed! I went through many rabbit holes to get to it of Linker settings, pointer functions and LoadLibrary/GetProcAddress. As it often is, the issue was fairly simple in the end. The reference to the third-party dll is linked to the chopDLL at run-time using the relative path set inside VisualStudio. I assumed this relative path was either relative to the .toe project file or to the location of the cpluspluschopDLL being linked within the toe file. Instead it looks like Touch is basing it’s relative path for these third party dlls from the TouchDesigner099.exe file. Once I copied the third-party dlls to this root folder of TouchDesigner099.exe it worked like a charm.

I’m not sure why this was the case, perhaps as this relative path is typically based off of the VS Solution path when the circumstances changed it used Touch’s path as the solution. Maybe my VS project isn’t linked correctly, but it would be nice if the other libraries the cplusplus chop are referencing could just live within the project’s directory.

Anyways, thanks for your help! It led to the inevitable answer :slight_smile:

I think what’s happening here isn’t a relative path or a visual studio setting issue. It’s just how Windows searches for .dlls. It’ll always search in the directory where the .exe is, so however you linked things doesn’t matter really. Windows doesn’t embed paths into the binaries, it just searches for .dlls using a complicated set of rules.

That makes sense! Thanks for the help and explanation :slight_smile: