调试ASP。NET web服务,c++ /CLI DLL,以及Visual Studio 2008中的本机DLL

时间:2022-06-01 21:39:21

I have a VS2008 solution with three projects: C# ASP.NET web service, which is using C++/CLI DLL, which in turn is calling functions of native C++ DLL. All references are properly set. In web service bin folder there are all three DLL's. Problem is when I hit F5 the page in my browser informs me about FileNotFoundException from HRESULT 0x8007007E, The specified module could not be found.

我有一个VS2008解决方案,有三个项目:c# ASP。NET web服务,它使用c++ /CLI DLL,反过来调用本机c++ DLL的函数。所有的引用都被正确设置。在web service bin文件夹中有三个DLL。问题是当我点击F5时,浏览器中的页面告诉我HRESULT 0x8007007E的FileNotFoundException,无法找到指定的模块。

The missing module is my native DLL. ASP.NET Development Server copies (and uses) my C++/CLI DLL somewhere in %USERPROFILE%\AppData\Local\Temp\Temporary ASP.NET Files\root, but not the native one. If I manually copy native DLL to the same folder with C++/CLI DLL then I can debug my web service. However, this copying does not seem right.

缺少的模块是我的本机DLL。ASP。NET开发服务器在%USERPROFILE%\AppData\本地\Temp\临时ASP中复制(并使用)我的c++ /CLI DLL。NET文件\root,但不是本地文件。如果我用c++ /CLI DLL手动将本机DLL复制到相同的文件夹中,那么我可以调试我的web服务。然而,这种复制似乎并不正确。

Copying native DLL somewhere on PATH does not feel right either, because other developers need to remember it.

在路径上的某个地方复制本地DLL也感觉不正确,因为其他开发人员需要记住它。

There is a similar question here, and a blog post linked in one answer. The given solution requires that I change DLL's to be delay-loaded, which again seems to much of a half-baked workaround, because it requires to change the end product due to development hurdles.

这里有一个类似的问题,一个博客文章链接在一个答案中。给定的解决方案要求我更改DLL的延迟加载,这在很大程度上也是一个不成熟的解决方案,因为由于开发障碍,它需要更改最终产品。

Is there a proper way to debug a combination of web service, C++CLI DLL, and native DLL?

是否有合适的方法来调试web服务、c++ CLI DLL和本机DLL的组合?

1 个解决方案

#1


3  

The issue is simply that the compiler can't figure out where the native c++ library is.

问题很简单,编译器无法找出本机c++库的位置。

So, there are a couple ways to fix that.

有几种方法可以解决这个问题。

  1. Use DLLImport to load the dll using a relative or absolute path at runtime.
  2. 使用DLLImport在运行时使用相对或绝对路径加载dll。
  3. Set the path environment variable to it's location.
  4. 将path环境变量设置为它的位置。
  5. Get really complicated in how the project is built (see link below, which you've obviously already read).
  6. 在项目的构建方式上变得非常复杂(请参阅下面的链接,显然您已经读过了)。

http://blogs.msdn.com/b/jorman/archive/2007/08/31/loading-c-assemblies-in-asp-net.aspx

http://blogs.msdn.com/b/jorman/archive/2007/08/31/loading-c-assemblies-in-asp-net.aspx

There's no real answer beyond those.

除了这些,没有真正的答案。

#1


3  

The issue is simply that the compiler can't figure out where the native c++ library is.

问题很简单,编译器无法找出本机c++库的位置。

So, there are a couple ways to fix that.

有几种方法可以解决这个问题。

  1. Use DLLImport to load the dll using a relative or absolute path at runtime.
  2. 使用DLLImport在运行时使用相对或绝对路径加载dll。
  3. Set the path environment variable to it's location.
  4. 将path环境变量设置为它的位置。
  5. Get really complicated in how the project is built (see link below, which you've obviously already read).
  6. 在项目的构建方式上变得非常复杂(请参阅下面的链接,显然您已经读过了)。

http://blogs.msdn.com/b/jorman/archive/2007/08/31/loading-c-assemblies-in-asp-net.aspx

http://blogs.msdn.com/b/jorman/archive/2007/08/31/loading-c-assemblies-in-asp-net.aspx

There's no real answer beyond those.

除了这些,没有真正的答案。