共用方式為


-linkresource (Visual Basic)

建立與 Managed 資源的連結。

語法

-linkresource:filename[,identifier[,public|private]]  

-linkres:filename[,identifier[,public|private]]  

引數

filename
必要。 要連結至組件的資源檔。 如果檔案名稱包含空格,請用引號 (" ") 括住名稱。

identifier
選擇性。 資源的邏輯名稱。 此名稱是用來載入資源的名稱。 預設值是檔案的名稱。 您可以視需要指定檔案在組件資訊清單中為公用或私用,例如:-linkres:filename.res,myname.res,public。 根據預設,filename 在組件中為公用。

備註

-linkresource 選項不會在輸出檔中內嵌資源檔;請使用 -resource 選項來執行此動作。

選項 -linkresource 需要 -target 的其中一個選項 (-target:module 除外)。

例如,如果 filename 是由 Resgen.exe (資源檔產生器) 或是在開發環境中所建立的 .NET Framework 資源檔,就可以使用 System.Resources 命名空間中的成員進行存取。 (如需詳細資訊,請參閱 ResourceManager。)若要在執行階段存取所有其他資源,請使用 Assembly 類別中以 GetManifestResource 開頭的方法。

檔案名稱可以是任何檔案格式。 例如,您可能需要產生組件的原生 DLL 部分,以便安裝到全域組件快取中,並從組件的 Managed 程式碼存取。

-linkresource 的簡短形式為 -linkres

注意

在 Visual Studio 開發環境中無法使用 -linkresource 選項;此選項只有在從命令列編譯時才可用。

範例

下列程式碼會編譯 in.vb 並連結至資源檔 rf.resource

vbc -linkresource:rf.resource in.vb  

另請參閱