简体   繁体   English

从网络共享启动应用程序时,混合模式C ++ DLL函数调用失败。 从非托管C应用程序调用

[英]Mixed Mode C++ DLL function call failure when app launched from network share. Called from unmanaged c application

Mixed-mode DLL called from native C application fails to load: An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module. 从本机C应用程序调用的混合模式DLL无法加载:未知模块中发生了类型为'System.IO.FileLoadException'的未处理异常。

Additional information: Could not load file or assembly 'XXSharePoint, Version=0.0.0.0, Culture=neutral, PublicKeyToken=e0fbc95fd73fff47' or one of its dependencies. 附加信息:无法加载文件或程序集'XXSharePoint,版本= 0.0.0.0,区域性=中性,PublicKeyToken = e0fbc95fd73fff47'或其依赖项之一。 Failed to grant minimum permission requests. 无法授予最低权限请求。 (Exception from HRESULT: 0x80131417) (来自HRESULT的异常:0x80131417)

My environment is: Native C application calling a mixed mode C++ DLL, which then loads a C# DLL.. This works correctly when loaded from a local drive, but when launched from a network drive, it fails with the above messages. 我的环境是:调用混合模式C ++ DLL的本机C应用程序,然后加载C#DLL。从本地驱动器加载时,此方法正确运行,但从网络驱动器启动时,则失败,并显示上述消息。

The call to LoadLibrary succeeds, as does the GetProcAddress. LoadLibrary的调用成功,GetProcAddress也成功。 The load error happens when I call the function. 当我调用函数时发生加载错误。

I have digitally signed the C application, and I've performed "strong name" signing on the 2 DLLs. 我已经对C应用程序进行了数字签名,并且已经在2个DLL上执行了“强名称”签名。 The PublickKeyToken in the message above does match the named DLL. 上面消息中的PublickKeyToken与命名的DLL匹配。 I have also issued the CASPOLcommands on my client to grant FullTrust to that strong name keytoken. 我还向客户端发出了CASPOL命令,以将FullTrust授予该强名称密钥令牌。 When that failed to work, I tried the CASPOL command to grant FullTrust to the URL of the network drive (including path to my application's directory); 如果无法正常工作,我尝试使用CASPOL命令将FullTrust授予网络驱动器的URL(包括应用程序目录的路径); no change in results. 结果没有变化。

I tried removing all dependencies, so that there was just the initial mixed-mode DLL... I replaced the bodies of all the functions with just a return of a "success" integer value. 我尝试删除所有依赖项,以便只有最初的混合模式DLL ...我只用“成功”整数值的返回值替换了所有函数的主体。 Results unchanged. 结果不变。 Only when I changed it from Mixed Mode to Win32, and changed the Configuration Properties >> General >> Common Language Runtime Support from "Common Language Runtime Support" to "No Common Language Runtime Support" did calling the DLL produce the expected result (just returned the "success" integer return value). 仅当我将其从混合模式更改为Win32,并将配置属性>>常规>>公共语言运行时支持从“公共语言运行时支持”更改为“无公共语言运行时支持”时,调用DLL才会产生预期的结果(只是返回“成功”整数返回值)。

You Haven't the permission to execute code on this share. 您无权在此共享上执行代码。 I think you can't exen execute any .NET app from the share. 我认为您无法从共享中执行任何.NET应用程序。 Try it out, place some .NET executable on the share, and try to execute it. 试用一下,在共享上放置一些.NET可执行文件,然后尝试执行它。 If it doesn't work, you have to add permission in your .net config to use the share. 如果不起作用,则必须在.net配置中添加权限才能使用共享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM