Support Board
Date/Time: Wed, 15 Jan 2025 16:21:37 +0000
Post From: C# code integration
[2017-07-31 21:19:31] |
DabbaDo - Posts: 148 |
The problem is that the c++/CLR dll (which is in the Data subfolder) ONLY looks in the executable directory (the main Sierra Chart folder) for any c# dlls. When it doesn't find them there, it throws you the eefileloadexception. IMHO the "proper" way to handle this would be with a ResolveEventHandler like the one below (copied from http://www.cplusplus.com/forum/windows/196600/. But SC would have to give us a hook that was called once, and preferably only once, during start-up (or at least sometime you call the study) so we could hook up the event. using namespace System; public ref class AssemblyResolver{ public: static System::Reflection::Assembly ^ResolveEventHandler(System::Object ^sender, System::ResolveEventArgs ^args){ auto sb = gcnew System::Text::StringBuilder(); sb->Append(GetAssemblyDirectory()); const char * const name = "\\required_assembly.dll"; for (auto p = name; *p; p++) sb->Append((Char)*p); return System::Reflection::Assembly::LoadFrom(sb->ToString()); } //Returns the containing directory of the assembly that contains the function. static String ^GetAssemblyDirectory(){ auto codeBase = System::Reflection::Assembly::GetExecutingAssembly()->CodeBase; auto uri = gcnew UriBuilder(codeBase); auto path = Uri::UnescapeDataString(uri->Path); return System::IO::Path::GetDirectoryName(path); } }; API Instance *initialize(){ auto domain = System::AppDomain::CurrentDomain; domain->AssemblyResolve += gcnew System::ResolveEventHandler(AssemblyResolver::ResolveEventHandler); //(Application-specific stuff) } |