![](/img/trans.png)
[英]How do I include all required assemblies when publishing C# console app that relies on EWS with Visual Studio 2013?
[英]In Visual Studio 2019, how do I add my project assemblies (or any assemblies at all) to the C# interactive pane?
提議的副本沒有回答這個問題。 當我右鍵單擊我的項目時,沒有“初始化與項目交互”選項。
我想在不創建另一個項目和編寫控制台應用程序的情況下測試一些代碼。 My project includes a reference to System.Windows.Forms
and I can use the Forms
namespace within my project, however, I cannot use it in C# interactive due to the following error:
> using System.Windows.Forms;
(1,22): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
我做了一些調查,但我找不到太多關於 Visual Studio 的這個特性的信息。 我想嘗試使用反射加載程序集,但是在加載程序集時確實有效,C# 交互式仍然找不到System.Windows.Forms
命名空間:
> Assembly.LoadFile("@C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\3.1.0\ref\netcoreapp3.1\System.Windows.Forms.dll")`
using System.Windows.Forms;
(1,14): error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)
請注意,我確保運行#reset core
以切換到 .NET Core 以匹配我嘗試加載的程序集版本。
無論是使用反射加載程序集還是更優雅的方法,如何在 Visual Studio 2019 的 C# 交互式窗格中以可用的方式加載非默認程序集?
對於 C# Interactive,您可以使用#r
指令直接加載 DLL。
只需執行以下操作:
> #r "C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\3.1.0\ref\netcoreapp3.1\System.Windows.Forms.dll"
或更通用:
> #r "C:\YOUR\DLL\PATH"
之后,您應該能夠從程序集中訪問命名空間。
您還可以使用 C# 交互式運行您的項目。 Just open the C# interactive window, then Right-Click the Project in your solution explorer, and select " Initialize Interactive with Project ", which will also load all of your project assemblies in C# interactive.
祝你好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.