Я использовал этот строительный блок для загрузки x86 / x64 версий hunspell в оболочку NHunspell за май может быть, это хорошая отправная точка для вашего собственного динамического загрузчика:
// Initialze the dynamic marshall Infrastructure to call the 32Bit (x86) or the 64Bit (x64) Dll respectively
SYSTEM_INFO info = new SYSTEM_INFO();
GetSystemInfo( ref info );
// Load the correct DLL according to the processor architecture
switch( info.wProcessorArchitecture )
{
case PROCESSOR_ARCHITECTURE.Intel:
string pathx86 = AppDomain.CurrentDomain.BaseDirectory;
if (!pathx86.EndsWith("\\"))
pathx86 += "\\";
pathx86 += Resources.HunspellX86DllName;
dllHandle = LoadLibrary(pathx86);
if (dllHandle == IntPtr.Zero)
throw new DllNotFoundException(string.Format(Resources.HunspellX86DllNotFoundMessage, pathx86));
break;
case PROCESSOR_ARCHITECTURE.Amd64:
string pathx64 = AppDomain.CurrentDomain.BaseDirectory;
if (!pathx64.EndsWith("\\"))
pathx64 += "\\";
pathx64 += Resources.HunspellX64DllName;
dllHandle = LoadLibrary(pathx64);
if (dllHandle == IntPtr.Zero)
throw new DllNotFoundException(string.Format(Resources.HunspellX64DllNotFoundMessage, pathx64));
break;
посмотрите на объявления этого делегата:
internal delegate bool HunspellSpellDelegate(IntPtr handle, [MarshalAs(UnmanagedType.LPWStr)] string word);
А как привязать к ней библиотечную функцию
HunspellSpell = (HunspellSpellDelegate)GetDelegate("HunspellSpell", typeof(HunspellSpellDelegate));
Я думаю, это должно работать и для вас, но вы должны объявить полный код взаимодействия. Вы можете проверить код Nhunspell, чтобы получить рабочий образец этой техники:
Веб-сайт NHunspell