简体   繁体   English

无法在 Visual Studio 2019 社区版 16.7.2 中使用外部应用程序调试 c# dll 项目

[英]Unable to debug c# dll project with an external app in Visual Studio 2019 Community edition 16.7.2

This project is an "amibroker plugin" developed in C# using kriasoft's amibroker .NET SDK .该项目是使用 kriasoft 的 amibroker .NET SDK 用 C# 开发的“amibroker 插件”。

I have "build" my plugin and it works fine when I test it in a "Console project".我已经“构建”了我的插件,当我在“控制台项目”中测试它时它工作正常。 But when I try to debug it with external app (Amibroker.exe) visual studio abruptly closes down and in a few seconds launches a blank visual studio window with an option to "attach" in place of where we usually see "start" for running our project.但是当我尝试使用外部应用程序 (Amibroker.exe) 调试它时,visual studio 突然关闭,并在几秒钟内启动一个空白的 Visual Studio 窗口,其中包含一个“附加”选项,而不是我们通常看到的“开始”运行我们的项目。

I clicked on the attach option and attached to my amibroker application and it successfully displayed "Debug.Writeline()" messages.我点击了附加选项并附加到我的 amibroker 应用程序,它成功显示了“Debug.Writeline()”消息。 But none of my breakpoints are hit.但是我的断点都没有被击中。 My code is not visible in any window either as it would be normally when I was debugging console app.我的代码在任何窗口中都不可见,就像我调试控制台应用程序时一样。

Upon research in google, i found out that the external application is supposed to be automatically launched by visual studio and should nave stopped at my breakpoint.在谷歌研究后,我发现外部应用程序应该由visual studio自动启动,并且应该在我的断点处停止。 This is not happening in my case.在我的情况下不会发生这种情况。 I have searched a lot and even updated entire vs2019, yet no progress.我搜索了很多,甚至更新了整个vs2019,但没有任何进展。

It would be great if anybody could help me out.如果有人可以帮助我,那就太好了。

Note: "Start without Debugging" works fine.注意:“开始而不调试”工作正常。

New Information regarding "Could not load file or assembly 'System.Text.Json": Could not load file or assembly 'System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.关于“无法加载文件或程序集“System.Text.Json”的新信息:无法加载文件或程序集“System.Text.Json,版本=4.0.1.1,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”或其依赖项之一. The system cannot find the file specified.该系统找不到指定的文件。

Err:510 LOG: DisplayName = System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/AmiBroker_New_6.0/ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). Err:510 LOG: DisplayName = System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/AmiBroker_New_6 .0/ 日志:初始 PrivatePath = NULL 调用程序集:(未知)。 Err:510 LOG: This bind starts in default load context.错误:510 日志:此绑定在默认加载上下文中启动。 LOG: No application configuration file found.日志:未找到应用程序配置文件。 LOG: Using host configuration file: LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config. LOG:使用主机配置文件: LOG:使用来自 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config 的机器配置文件。 LOG: Post-policy reference: System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 LOG: Attempting download of new URL file:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json.DLL.日志:后政策参考:System.Text.Json,版本=4.0.1.1,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51 日志:正在尝试下载新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0 /System.Text.Json.DLL。 LOG: Attempting download of new URL file:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json/System.Text.Json.DLL.日志:正在尝试下载新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json/System.Text.Json.DLL。 LOG: Attempting download of new URL file:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json.EXE.日志:正在尝试下载新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json.EXE。 LOG: Attempting download of new URL file:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json/System.Text.Json.EXE.日志:正在尝试下载新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json/System.Text.Json.EXE。

My packages.config entries:我的packages.config条目:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CsvTextFieldParser" version="1.2.1" targetFramework="net461" />
  <package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net461" />
  <package id="System.Buffers" version="4.5.1" targetFramework="net461" />
  <package id="System.Memory" version="4.5.4" targetFramework="net461" />
  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
  <package id="System.Text.Encodings.Web" version="4.7.1" targetFramework="net461" />
  <package id="System.Text.Json" version="4.7.1" targetFramework="net461" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net461" />
  <package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
  <package id="UnmanagedExports" version="1.2.7" targetFramework="net461" />
</packages>

app.config应用程序配置文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <probing privatePath="ghyiouys\;Plugins\;plugins;"/>
            <dependentAssembly>
                <assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
                <codeBase version="4.0.1.1" href="Plugins/System.Text.Json.dll"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
                <codeBase version="4.1.4.0" href="Plugins/System.Numerics.Vectors.dll"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Unable to debug c# dll project with an external app in Visual Studio 2019 Community edition 16.7.2无法在 Visual Studio 2019 社区版 16.7.2 中使用外部应用程序调试 c# dll 项目

If you just want to step into the breakpoint just with the external program under the debug process through one VS, it cannot be done since VS cannot load the pdb files through the external program.如果你只是想通过一个VS调试过程下的外部程序单步进入断点,是无法做到的,因为VS无法通过外部程序加载pdb文件。 And Start without Debugging will not loads the pdb file so that it works well.并且Start without Debugging不会加载 pdb 文件,因此它运行良好。

As a suggestion ,作为建议

You must additionally start a new vs instance to debug the project through attach to process at the same time.您必须另外启动一个新的 vs 实例来同时通过attach to process调试项目。

Using the second suggestion will realize it.使用第二个建议将实现它。

1) First , you should check your extra program: 1) 首先,你应该检查你的额外程序:

在此处输入图片说明

The start external program is the full path of your Amibroker.exe and the Command line arguments contains the name of your current project amibroker plugin in VS.启动外部程序是您的Amibroker.exe的完整路径,命令行参数包含您在 VS 中当前项目的 amibroker 插件的名称。

Then , uncheck the option Enable Just My Code under Tools --> Options --> Debugging --> General .然后,取消选中工具-->选项-->调试-->常规下的启用仅我的代码选项

2) Second , remember to add Debugger.Launch(); 2) 其次,记得添加Debugger.Launch(); under the Main function in your cs file like this:在您的 cs 文件中的 Main 函数下,如下所示:

 static void Main(string[] args)
        {
            Debugger.Launch();

            //add any code here

        }

3) Third , click Start Debugging and then open Debug --> Windows --> Modules and then search any dlls about Amibroker and then right-click on them--> Always Load Automatically . 3) 第三,单击Start Debugging ,然后打开调试--> Windows -->模块,然后搜索有关Amibroker任何 dll,然后右键单击它们-->始终自动加载

4) Fourth , stop Debug process and then delete bin and obj folder. 4) 第四,停止Debug进程,然后删除binobj文件夹。 After that, click Start Debugging again, wait for a moment, and you can see the window about Choose the Just-In-Time Debugger window.之后,再次单击Start Debugging ,稍等片刻,您将看到有关Choose the Just-In-Time Debugger窗口的窗口。 You should select VS2019 IDE and it starts a new vs instance with the current project by attach into process .您应该选择VS2019 IDE ,它会通过attach into process使用当前项目启动一个新的 vs 实例。 And with it, you can step into the breakpoint to debug the code.有了它,你就可以进入断点调试代码。

在此处输入图片说明

Or you could try my second suggestion to start the process automatically.或者您可以尝试我的第二个建议以自动启动该过程。

Note : the second suggestion will create a new VS Instance by Attach to Process with your amibroker plugin project at the same time.注意:第二个建议将通过附加到进程与您的 amibroker 插件项目同时创建一个新的 VS 实例。

=========================================== ============================================

Besides , if you still face the same issue, please try to disable any third party extensions under Extensions menu--> Manage Extensions to check if there is something causing it.此外,如果您仍然遇到同样的问题,请尝试在“扩展”菜单-->“管理扩展”下禁用任何第三方扩展,以检查是否有问题导致。

Also , Reset All VS settings by Tools --> Options --> Import and Export Settings --> Reset All Settings and then disable the option Enable Just My Code option .此外,通过工具->选项->导入和导出设置->重置所有设置重置所有 VS 设置,然后禁用选项启用仅我的代码选项

Also , there is a similar issue about it .此外,还有一个类似的问题

暂无
暂无

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

相关问题 在 Visual Studio 2019 社区中将 Azure API 链接到 C# ASP.Net 项目的问题 - Issue linking Azure API to C# ASP.Net project in Visual Studio 2019 Community 如何在 Visual Studio 2019 社区版中将我的发布项目转换为安装程序? - How do I turn my release project into an installer in Visual Studio 2019 Community Edition? Visual Studio 2019 社区版是否支持 MVC 5 项目? - Does Visual Studio 2019 community edition support MVC 5 projects? 外部DLL Visual Studio C#错误 - external dll visual studio C# error 无法在设计器视图中的 ASP.NET Web Forms (C#) 的 Visual Studio Community Edition 2022 中拖放或编辑工具箱元素 - Unable to drag and drop or edit toolbox elements in Visual Studio Community Edition 2022 for ASP.NET Web Forms (C#) in Designer View 在Visual Studio Express Edition C#中确定.dll依赖项 - Determining .dll dependencies in Visual Studio Express Edition C# 无法将Visual Studio制作的C ++ DLL导入Windows上的Visual Studio C#项目 - Unable to Import a Visual Studio made C++ DLL into a Visual Studio C# Project on Windows Visual Studio 2019 将 C# 程序导出为 DLL 而不是 EXE? - Visual Studio 2019 Exports C# Program as DLL instead of EXE? UWP 应用程序在 Visual Studio 调试模式下工作,但发布版本无法运行,缺少 DLL (C#) - UWP App works in Visual Studio debug mode, but the release build won't run, missing DLL (C#) Visual Studio社区版Windows Phone应用程序丢失 - Visual Studio community edition windows phone app missing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM