簡體   English   中英

C# 站點未加載:未設置環境變量

[英]C# site not loading: environment variable not set

我有一個 ASPX C# web 應用程序,我正在嘗試將其遷移到測試服務器。 該 Web 應用程序在我的實時服務器上運行良好,但在我的測試服務器上嘗試運行時遇到以下錯誤。 我復制了項目源代碼。

當我嘗試從本地計算機瀏覽站點時,我收到以下錯誤消息(出於安全原因,我正在更改環境變量的名稱,我將其ThisVariable ):

ThisVariable environment variable not set. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.ApplicationException: ThisVariable environment variable not set.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  


[ApplicationException: ThisVariable environment variable not set.]
   ThisVariable.Common.Configuration.BaseConfiguration.GetThisVariableHome() +203
   ThisVariable.Common.Configuration.BaseConfiguration.Initialize(String configFileName) +84
   ThisVariable.City.Web.Application.Test.Global.Application_Start(Object sender, EventArgs e) in D:\Src\Tfs\Customers\City\Test\Source\DotNet\Application\Web\TestWebApplication\Global.asax.cs:17

我做的第一件事就是在我的實時站點上准確地設置該環境變量。 相同的拼寫和文件路徑。 現在在我的CMD如果我回顯該變量,我會返回: C:\\ThisVariable

在我的web.config文件中,我在這里找到了這一行:

<file type="log4net.Util.PatternString" value="%env{ThisVariable}\Logs\ThisVariable.City.Web.Application.Test" />

ApplicationException錯誤日志中,它引用了我的 D 驅動器上的路徑,但我的 D 驅動器中沒有任何內容。 然而,我的項目文件夾中有一個Global.asax ,但它只有一行包含以下代碼:

<%@ Application Codebehind="Global.asax.cs" Inherits="ThisVariable.City.Web.Application.Test.Global" Language="C#" %>

有任何想法嗎?

沒有關於這些是用戶環境變量還是系統環境變量的全貌,我的第一個假設是這些是用戶變量: 用戶變量和系統變量之間有什么區別?

如果是這種情況,請在此處檢查: IIS 不使用用戶環境變量

如果要使用用戶特定的環境變量,則應將應用程序池設置 LoadUserProfile 設置為 true(默認值為 false),

否則,設置系統變量並重新啟動 iis,或者如果失敗,則重新啟動機器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM