Shadow Copying,以及从任意文件夹加载的混合C#和C ++ DLL

时间:2022-09-01 19:21:04

I have a VS 2005 C# project that uses a special Plugin folder to load extra DLLs (for use as nodes in an asset conversion process).

我有一个VS 2005 C#项目,它使用一个特殊的Plugin文件夹来加载额外的DLL(用作资产转换过程中的节点)。

I have a mixture of C# and C++ DLLs in this folder.

我在这个文件夹中混合使用C#和C ++ DLL。

The issue I have is that when Shadow Copying is enabled, the C++ DLLs refuse to load using Assembly.LoadFrom. I have attempted to create a custom app domain, and used Load, but this also failed.

我遇到的问题是,启用卷影复制时,C ++ DLL拒绝使用Assembly.LoadFrom加载。我试图创建一个自定义应用程序域,并使用Load,但这也失败了。

Finally, I tried reading the DLL in as byte[] data and using Load on that - again, only the C# DLLs would work this way, with an error "Additional information: Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)".

最后,我尝试在byte []数据中读取DLL并使用Load on - 再次,只有C#DLL会以这种方式工作,并出现错误“附加信息:无法验证的代码失败策略检查。(HRESULT异常:0x80131402) ”。

An article on the net prompted me to attempt to use /clr:safe when building that particular DLL, but then it simply failed to build due to thousands of errors in Microsoft code... (apparently)

网上的一篇文章促使我在构建特定的DLL时尝试使用/ clr:safe,但由于Microsoft代码中存在数千个错误而导致它无法构建...(显然)

With Shadow Copying disabled, LoadFrom works fine for all DLLs. The app is itself a plugin for Maya, and this used to work with Maya 8.5 but fails with 2008 / 2009 (if Shadow Copying is enabled).

禁用阴影复制后,LoadFrom适用于所有DLL。该应用程序本身是Maya的一个插件,这曾经与Maya 8.5一起使用,但在2008/2009年失败(如果启用了Shadow Copying)。

We really would prefer to use Shadow Copying, because it prevents DLL file locks when the app is running (the Plugins folder is stored in a location that Perforce can update while the app is running).

我们真的更喜欢使用Shadow Copying,因为它可以在应用程序运行时阻止DLL文件锁定(Plugins文件夹存储在Perforce可以在应用程序运行时更新的位置)。

Any ideas as to how I can persuade Shadow Copying to work with a custom folder AND a mix of C# / C++ DLLs without these problems?

关于如何说服Shadow Copying使用自定义文件夹和混合使用C#/ C ++ DLL而没有这些问题的任何想法?

2 个解决方案

#1


1  

Sounds like a trust issue. Try getting a Fusion log (see this blog post). Your C++ DLLs are unverifiable since they weren't compiled with /clr:safe, so they can only be loaded as full trust. Presumably when shadow copying, the download cache location doesn't have full trust.

听起来像一个信任问题。尝试获取Fusion日志(请参阅此博客文章)。您的C ++ DLL无法验证,因为它们未使用/ clr:safe编译,因此它们只能作为完全信任加载。据推测,当影子复制时,下载缓存位置没有完全信任。

Running caspol -s may get you up and running if this is a development-only issue.

如果这是一个仅限开发的问题,运行caspol -s可能会让您启动并运行。

#2


0  

Assembly.Load(byte[] ...) explicitly disallows unverifiable (mixed mode) assemblies. you can check the issue on Microsoft Connect.

Assembly.Load(byte [] ...)明确禁止无法验证(混合模式)程序集。您可以检查Microsoft Connect上的问题。

#1


1  

Sounds like a trust issue. Try getting a Fusion log (see this blog post). Your C++ DLLs are unverifiable since they weren't compiled with /clr:safe, so they can only be loaded as full trust. Presumably when shadow copying, the download cache location doesn't have full trust.

听起来像一个信任问题。尝试获取Fusion日志(请参阅此博客文章)。您的C ++ DLL无法验证,因为它们未使用/ clr:safe编译,因此它们只能作为完全信任加载。据推测,当影子复制时,下载缓存位置没有完全信任。

Running caspol -s may get you up and running if this is a development-only issue.

如果这是一个仅限开发的问题,运行caspol -s可能会让您启动并运行。

#2


0  

Assembly.Load(byte[] ...) explicitly disallows unverifiable (mixed mode) assemblies. you can check the issue on Microsoft Connect.

Assembly.Load(byte [] ...)明确禁止无法验证(混合模式)程序集。您可以检查Microsoft Connect上的问题。