混合模式 C++从网络共享启动应用程序时,DLL 函数调用失败。从非托管 C 应用程序调用
从本机 C 应用程序调用的混合模式 DLL 无法加载: 未知模块中发生“System.IO.FileLoadException”类型的未处理异常。
其他信息:无法加载文件或程序集“XXSharePoint,Version=0.0.0.0,Culture=neutral,PublicKeyToken=e0fbc95fd73fff47”或其依赖项之一。无法授予最低权限请求。 (HRESULT 异常:0x80131417)
我的环境是:调用混合模式 C++ DLL 的本机 C 应用程序,然后加载 C# DLL。从本地驱动器加载时可以正常工作,但从网络驱动器启动时,它会失败并显示上述消息。
对 LoadLibrary 的调用成功,对 GetProcAddress 的调用也成功。当我调用该函数时发生加载错误。
我已经对 C 应用程序进行了数字签名,并对 2 个 DLL 执行了“强名称”签名。上面消息中的 PublickKeyToken 确实与指定的 DLL 匹配。我还在我的客户端上发出了 CASPOL 命令,以授予该强名称密钥令牌完全信任。当这不起作用时,我尝试使用 CASPOL 命令将 FullTrust 授予网络驱动器的 URL(包括我的应用程序目录的路径);结果没有变化。
我尝试删除所有依赖项,以便只剩下最初的混合模式 DLL...我用返回的“成功”整数值替换了所有函数的主体。结果不变。仅当我将其从混合模式更改为Win32,并更改配置属性>>>时一般>>公共语言运行时支持从“公共语言运行时支持”到“无公共语言运行时支持”调用 DLL 确实产生了预期结果(仅返回“成功”整数返回值)。
Mixed-mode DLL called from native C application fails to load:
An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.
Additional information: Could not load file or assembly 'XXSharePoint, Version=0.0.0.0, Culture=neutral, PublicKeyToken=e0fbc95fd73fff47' or one of its dependencies. Failed to grant minimum permission requests. (Exception from 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.
The call to LoadLibrary succeeds, as does the 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. The PublickKeyToken in the message above does match the named DLL. I have also issued the CASPOLcommands on my client to grant FullTrust to that strong name keytoken. 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); 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. 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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无权在此共享上执行代码。我认为您无法从共享中执行任何 .NET 应用程序。尝试一下,在共享上放置一些 .NET 可执行文件,然后尝试执行它。如果它不起作用,您必须在 .net 配置中添加权限才能使用共享。
You Haven't the permission to execute code on this share. I think you can't exen execute any .NET app from the share. Try it out, place some .NET executable on the share, and try to execute it. If it doesn't work, you have to add permission in your .net config to use the share.