![](/img/trans.png)
[英]Visual Studio - Intellisense not recognizing namespace in another project within same solution
[英]Visual Studio for Mac: Logs work on a Project and are shown on Azure, but fail on another Project of same Solution
在解決方案的主要項目中,我有:
public static void Main(string[] args)
{
// Testing Logs on Azure Application Insights:
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
telemetry.TrackTrace("Test of ApplicationInsights.TelemetryClient() on Program.cs");
CreateWebHostBuilder(args).Build().Run();
}
它正在運行,並且日志正在Azure應用程序見解中顯示。
不幸的是,當我將相同的代碼添加到相同解決方案的另一個項目中時,它不起作用:而是在Azure上引發異常。
我試圖添加對主項目的引用(因為我認為這將導入其項目和其他所需的內容)。 不幸的是我不能,因為它說:
不允許循環依賴
因此,我在解決方案的其他項目中添加了相同的細節。 這樣,它便可以編譯,並且我可以上傳到Azure。 但是由於該錯誤,我看不到日志(跟蹤):
在Azure上顯示的日志的文本版本(Trace):
AI (Internal): [Microsoft-ApplicationInsights-AspNetCore-StartupBootstrapper] Could not load Microsoft.AspNetCore.ApplicationInsights.HostingStartup. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.ApplicationInsights.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.ApplicationInsights.HostingStartup, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, StackCrawlMark& stackMark, IntPtr pPrivHostBinder)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.ApplicationInsights.AssemblyLoader.Load(String assemblyName)
at StartupBootstrapper.Startup.TryLoadStartupAssembly(String assemblyName)
我正在使用Visual Studio for Mac(又名VS for mac 2019)。 請注意,它實際上不同於Windows的Visual Studio: 使用Windows的Visual Studio在Azure上調試要容易得多!
我究竟做錯了什么?
嘗試通過nuget軟件包管理器或dotnet cli命令將軟件包添加到項目中
dotnet add package Microsoft.ApplicationInsights --version 2.10.0
如果已經安裝,請嘗試重新安裝並獲取最新信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.