简体   繁体   English

VS2012中的DLL加载(C#/ IronPython / C#)

[英]DLL loading (C#/IronPython/C#) in VS2012

I want to debug separate pieces of my application in Visual Studio 2012. 我想在Visual Studio 2012中调试应用程序的各个部分。

I have C# executable which works with Oracle.DataAccess dll. 我有与Oracle.DataAccess dll一起使用的C#可执行文件。 It works fine. 工作正常。 Within it IronPython runtime is invoked and it works fine too. 在其中调用IronPython运行时,它也可以正常运行。 Within these IronPython modules object from main C# application is invoked and it works fine with Oracle dll. 在这些IronPython模块中,将调用来自主C#应用程序的对象,并且该对象可以与Oracle dll正常工作。

If IronPython script is invoked standalone then it works fine and uses C# object fine as well. 如果IronPython脚本是独立调用的,则可以正常工作,并且也可以使用C#对象。

However in this case C# object doesn't see Oracle dll. 但是,在这种情况下,C#对象看不到Oracle dll。

To debug IronPython scripts I have to create separate Python solution so I cannot configure my C# solution. 要调试IronPython脚本,我必须创建单独的Python解决方案,因此无法配置C#解决方案。 So I do not have control of C# references. 因此,我无法控制C#引用。 GAC has right Oracle dll but how to tell C# dll to use it? GAC拥有正确的Oracle dll,但是如何告诉C#dll使用它?

Vise versa if I'm in C# solution where I can manage the references then I cannot add py files and debug them. 反之亦然,如果我在C#解决方案中可以管理引用,则无法添加py文件并对其进行调试。

In what way can I configure VS to be able to run/debug my application with dual entry C# or IronPython separately? 我可以通过哪种方式配置VS使其能够分别使用双输入C#或IronPython来运行/调试应用程序?

You can try replicating what "works for me". 您可以尝试复制“对我有用”的内容。 Create a solution containing: 创建一个包含以下内容的解决方案:

  • python project (ironpython) python项目(ironpython)
  • C# project C#项目

Add a reference to desired oracle library (Oracle.DataAccess.dll) to C# project using the standard VS mechanism. 使用标准VS机制向C#项目添加对所需oracle库(Oracle.DataAccess.dll)的引用。 C# project should also contains a post build step to copy the resulting dll and pdb into the place where python script can find it. C#项目还应包含一个构建后步骤,用于将生成的dll和pdb复制到python脚本可以找到它的位置。 In my case root of the python project. 以我为例,python项目的根目录。

Your python project is selected as Startup Project. 您的python项目被选为Startup Project。 I use Ctrl-F5 and F5 to start it. 我使用Ctrl-F5和F5启动它。 In both cases things work as expected. 在这两种情况下,事情都按预期进行。 In debug mode I am able to set and hit breakpoint in python and in referenced C# module. 在调试模式下,我可以在python和引用的C#模块中设置并击中断点。 I can see the oracle library being loaded (Output window of debugger). 我可以看到正在加载oracle库(调试器的“输出”窗口)。

However: 然而:

  • The stack traces are C# only. 堆栈跟踪仅是C#。
  • Visual Studio 2013 Update 4 together with PTVS 2.1 crashes on occasions when debugging. 调试时,Visual Studio 2013 Update 4和PTVS 2.1一起崩溃。

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

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