診斷 Windows 執行階段元件錯誤狀況Diagnosing Windows Runtime Component error conditions

本文提供以 managed 程式碼撰寫 Windows 執行階段元件限制的其他相關資訊。This article provides additional information about restrictions on Windows Runtime components written with managed code. 它會展開 Winmdexp.exe (Windows 執行階段中繼資料匯出工具) 中的錯誤訊息所提供的資訊,並補充 使用 c # 和 Windows 執行階段 Visual Basic 元件中提供的限制資訊。It expands on the information that is provided in error messages from Winmdexp.exe (Windows Runtime Metadata Export Tool), and complements the information on restrictions that is provided in Windows Runtime components with C# and Visual Basic.

本文並未涵蓋所有錯誤。This article doesn’t cover all errors. 本文討論的錯誤會依照一般類別分門別類,而每個類別都有一個相關錯誤訊息的表格。The errors discussed here are grouped by general category, and each category includes a table of associated error messages. 請搜尋訊息文字 (省略預留位置的特定值) 或訊息編號。Search for message text (omitting specific values for placeholders) or for message number. 如果您在此處找不到所需的資訊,請使用本文結尾處的意見反應按鈕來協助我們改善本文。If you don’t find the information you need here, please help us improve the documentation by using the feedback button at the end of this article. 請納入錯誤訊息。Include the error message. 或者,您也可以將 Bug 歸檔在 Microsoft Connect 網站上。Alternatively, you can file a bug at the Microsoft Connect website.

實作非同步介面提供不正確類型的錯誤訊息Error message for implementing async interface provides incorrect type

Managed Windows 執行階段元件無法執行通用 Windows 平臺 (UWP) 介面,這些介面代表非同步動作或作業 (IAsyncActioniasyncactionwithprogress iasyncoperation < TProgress > iasyncoperationHTTP < TResult > IAsyncOperationWithProgress < TResult、TProgress > ) 。Managed Windows Runtime components cannot implement the Universal Windows Platform (UWP) interfaces that represent asynchronous actions or operations (IAsyncAction, IAsyncActionWithProgress<TProgress>, IAsyncOperation<TResult>, or IAsyncOperationWithProgress<TResult, TProgress>). 相反地,.NET 會提供 system.runtime.interopservices.windowsruntime.asyncinfo 類別,以便在 Windows 執行階段元件中產生非同步作業。Instead, .NET provides the AsyncInfo class for generating async operations in Windows Runtime components. 當您嘗試以不正確的方式實作非同步介面時,Winmdexp.exe 顯示的錯誤訊息會根據這個類別的舊名稱 AsyncInfoFactory 指出這個類別,The error message that Winmdexp.exe displays when you try to implement an async interface incorrectly refers to this class by its former name, AsyncInfoFactory. .NET 不再包含 System.runtime.interopservices.windowsruntime.asyncinfofactory 類別。.NET no longer includes the AsyncInfoFactory class.

錯誤號碼Error number 訊息文字Message Text
WME1084WME1084 類型 ' {0} ' implements Windows 執行階段 async interface ' {1} '。Type '{0}' implements Windows Runtime async interface '{1}'. Windows 執行階段類型不能實作非同步介面。Windows Runtime types cannot implement async interfaces. 請使用 System.Runtime.InteropServices.WindowsRuntime.AsyncInfoFactory 類別產生非同步作業,以匯出到 Windows 執行階段。Please use the System.Runtime.InteropServices.WindowsRuntime.AsyncInfoFactory class to generate async operations for export to Windows Runtime.

注意  參考 Windows 執行階段的錯誤訊息會使用舊的術語。Note The error messages that refer to the Windows Runtime use an old terminology. 這現在稱為通用 Windows 平台 (UWP)。This is now referred to as the Universal Windows Platform (UWP). 例如,Windows 執行階段類型現在稱為 UWP 類型。For example, Windows Runtime types are now called UWP types.

遺失 mscorlib.dll 或 System.Runtime.dll 的參考Missing references to mscorlib.dll or System.Runtime.dll

僅在從命令列使用 Winmdexp.exe 時,才會發生此問題。This issue occurs only when you use Winmdexp.exe from the command line. 建議您使用/reference 選項,以從 .NET Framework 核心參考元件(位於 "% ProgramFiles (x86) % \ Reference 元件 Microsoft Framework)中包含 mscorlib.dll 和 System.Runtime.dll 的參考 \ \ \ 。NETCore \ 4.5 " ("% ProgramFiles% \ ... "在32位電腦上) 。We recommend that you use the /reference option to include references to both mscorlib.dll and System.Runtime.dll from the .NET Framework core reference assemblies, which are located in "%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5" ("%ProgramFiles%\..." on a 32-bit computer).

錯誤號碼Error number 訊息文字Message Text
WME1009WME1009 未參考 mscorlib.dll。No reference was made to mscorlib.dll. 必須有這個中繼資料檔的參考,才能正確匯出。A reference to this metadata file is required in order to export correctly.
WME1090WME1090 無法判斷核心參考組件。Could not determine the core reference assembly. 請確定已使用 /reference 參數參考 mscorlib.dll 和 System.Runtime.dll。Please make sure mscorlib.dll and System.Runtime.dll is referenced using the /reference switch.

不允許運算子多載Operator overloading is not allowed

在使用 Managed 程式碼撰寫的 Windows 執行階段元件中,您無法公開公用類型的多載運算子。In a Windows Runtime Component written in managed code, you cannot expose overloaded operators on public types.

注意  在錯誤訊息中,運算子是以其中繼資料名稱來識別,例如 op _ 加法、op _ 乘法、op _ ExclusiveOr、op _ 隱含 (隱含轉換) 等等。Note In the error message, the operator is identified by its metadata name, such as op_Addition, op_Multiply, op_ExclusiveOr, op_Implicit (implicit conversion), and so on.

錯誤號碼Error number 訊息文字Message Text
WME1087WME1087 ' {0} ' 是運算子多載。'{0}' is an operator overload. Managed 類型無法在 Windows 執行階段中公開運算子多載。Managed types cannot expose operator overloads in the Windows Runtime.

一個類別的建構函式具有相同數量的參數Constructors on a class have the same number of parameters

在 UWP 中,一個類別只能有一個具有指定數量參數的建構函式,例如,您不能有一個建構函式具有類型 String 的單一參數,同時又有一個建構函式具有類型 int (在 Visual Basic 中為 Integer) 的單一參數。In the UWP, a class can have only one constructor with a given number of parameters; for example, you can't have one constructor that has a single parameter of type String and another that has a single parameter of type int (Integer in Visual Basic). 唯一的解決方法是對每個建構函式使用不同數量的參數。The only workaround is to use a different number of parameters for each constructor.

錯誤號碼Error number 訊息文字Message Text
WME1099WME1099 類型 ' {0} ' 有多個具有 ' {1} ' 引數 (s 的函式) 。Type '{0}' has multiple constructors with '{1}' argument(s). Windows 執行階段類型不能有多個引數數目相同的建構函式。Windows Runtime types cannot have multiple constructors with the same number of arguments.

對於具有相同參數數量的多載,必須指定預設值Must specify a default for overloads that have the same number of parameters

在 UWP 中,只有將某個多載指定為預設多載後,多載方法才可以有相同數量的參數。In the UWP, overloaded methods can have the same number of parameters only if one overload is specified as the default overload. 請參閱 使用 c # 和 Visual Basic Windows 執行階段元件中的「多載方法」。See "Overloaded Methods" in Windows Runtime components with C# and Visual Basic.

錯誤號碼Error number 訊息文字Message Text
WME1059WME1059 {0}'. ' 的多重參數多載 {1} {2} 會以 windows.foundation.metadata.defaultoverloadattribute 裝飾的方式裝飾。Multiple {0}-parameter overloads of '{1}.{2}' are decorated with Windows.Foundation.Metadata.DefaultOverloadAttribute.
WME1085WME1085 的 {0} -參數多載 {1} {2} 只能以 windows.foundation.metadata.defaultoverloadattribute 裝飾的方式,將其指定為預設多載。The {0}-parameter overloads of {1}.{2} must have exactly one method specified as the default overload by decorating it with Windows.Foundation.Metadata.DefaultOverloadAttribute.

命名空間錯誤且輸出檔的名稱無效Namespace errors and invalid names for the output file

在通用 Windows 平台中,Windows 中繼資料 (.winmd) 檔案中的所有公用類型必須位於共用 .winmd 檔案名稱的命名空間中,或位於該檔案名稱的子命名空間中。In the Universal Windows Platform, all the public types in a Windows metadata (.winmd) file must be in a namespace that shares the .winmd file name, or in sub-namespaces of the file name. 例如,如果您的 Visual Studio 專案名稱為 A.B (也就是說,您的 Windows 執行階段元件為 A.B.winmd),則此專案可包含公用類別 A.B.Class1 與 A.B.C.Class2,但不可包含 A.Class3 (WME0006) 或 D.Class4 (WME1044)。For example, if your Visual Studio project is named A.B (that is, your Windows Runtime Component is A.B.winmd), it can contain public classes A.B.Class1 and A.B.C.Class2, but not A.Class3 (WME0006) or D.Class4 (WME1044).

注意 這些限制僅適用於公用類型,而不適用於您的實作所使用的私用類型。Note These restrictions apply only to public types, not to private types used in your implementation.

以 A.Class3 為例,您可以將 Class3 移至其他命名空間,或將 Windows 執行階段元件的名稱變更為 A.winmd。In the case of A.Class3, you can either move Class3 to another namespace or change the name of the Windows Runtime Component to A.winmd. 雖然 WME0006 是警告,但您應將其視為錯誤。Although WME0006 is a warning, you should treat it as an error. 在上述範例中,呼叫 A.B.winmd 的程式碼將找不到 A.Class3。In the previous example, code that calls A.B.winmd will be unable to locate A.Class3.

以 D.Class4 為例,沒有任何檔案名稱可同時包含 D.Class4 與 A.B 命名空間中的類別,因此變更 Windows 執行階段元件的名稱是不可行的。In the case of D.Class4, no file name can contain both D.Class4 and classes in the A.B namespace, so changing the name of the Windows Runtime Component is not an option. 您可以將 D.Class4 移至另一個命名空間,或將其放在另一個 Windows 執行階段元件中。You can either move D.Class4 to another namespace, or put it in another Windows Runtime Component.

檔案系統無法區分大小寫,因此不允許只有大小寫不同的命名空間 (WME1067)。The file system can't distinguish between uppercase and lowercase, so namespaces that differ by case are not allowed (WME1067).

您的元件至少必須包含一個 public sealed 類型 (在 Visual Basic 中為 Public NotInheritable)。Your component must contain at least one public sealed type (Public NotInheritable in Visual Basic). 否則,根據您的元件是否包含私用類型而定,將會出現 WME1042 或 WME1043。If not, you will get WME1042 or WME1043, depending on whether your component contains private types.

Windows 執行階段元件中的類型不可與命名空間同名 (WME1068)。A type in a Windows Runtime Component cannot have a name that is the same as a namespace (WME1068).

警告 如果您直接呼叫 Winmdexp.exe,而未使用 /out 選項來為您的 Windows 執行階段元件指定名稱,Winmdexp.exe 即會嘗試產生包含元件中所有命名空間的名稱。Caution If you call Winmdexp.exe directly and don't use the /out option to specify a name for your Windows Runtime Component, Winmdexp.exe tries to generate a name that includes all the namespaces in the component. 為命名空間重新命名,可變更元件的名稱。Renaming namespaces can change the name of your component.

 

錯誤號碼Error number 訊息文字Message Text
WME0006WME0006 ' {0} ' 不是此元件的有效 winmd 檔案名。'{0}' is not a valid winmd file name for this assembly. Windows 中繼資料檔中的所有類型都必須存在檔名所隱含之命名空間的子命名空間內。All types within a Windows Metadata file must exist in a sub namespace of the namespace that is implied by the file name. 執行階段找不到不存在於這種子命名空間的類型。Types that do not exist in such a sub namespace cannot be located at runtime. 在這個組件中,可做為檔名的最小通用命名空間是 '{1}'。In this assembly, the smallest common namespace that could serve as a filename is '{1}'.
WME1042WME1042 輸入模組必須至少包含一個位在命名空間內的公用類型。Input module must contain at least one public type that is located inside a namespace.
WME1043WME1043 輸入模組必須至少包含一個位在命名空間內的公用類型。Input module must contain at least one public type that is located inside a namespace. 在命名空間內只發現私用類型。The only types found inside namespaces are private.
WME1044WME1044 公用類型具有命名空間 ( ' {1} ' ) ,此命名空間與其他命名空間 ( ' ' ) 不共用任何一般前置詞 {0} 。A public type has a namespace ('{1}') that shares no common prefix with other namespaces ('{0}'). Windows 中繼資料檔中的所有類型都必須存在檔名所隱含之命名空間的子命名空間內。All types within a Windows Metadata file must exist in a sub namespace of the namespace that is implied by the file name.
WME1067WME1067 命名空間名稱不可只有大小寫不同: ' {0} '、' {1} '。Namespace names cannot differ only by case: '{0}', '{1}'.
WME1068WME1068 類型 ' {0} ' 不能與命名空間 ' ' 具有相同的名稱 {1} 。Type '{0}' cannot have the same name as namespace '{1}'.

匯出的類型不是有效的通用 Windows 平台類型Exporting types that aren't valid Universal Windows Platform types

元件的公用介面必須只公開 UWP 類型。The public interface of your component must expose only UWP types. 不過,.NET 會提供一些在 .NET 和 UWP 中稍有不同之常用類型的對應。However, .NET provides mappings for a number of commonly used types that are slightly different in .NET and the UWP. 這可讓 .NET 開發人員使用熟悉的類型,而不是學習新的型別。This enables the .NET developer to work with familiar types instead of learning new ones. 您可以在元件的公用介面中使用這些對應的 .NET 類型。You can use these mapped .NET types in the public interface of your component. 請參閱 使用 c # 和 Visual Basic 的 Windows 執行階段元件中的「在 Windows 執行階段元件中宣告型別」和「將通用 Windows 平臺型別傳遞至 managed 程式碼」,以及 Windows 執行階段類型的 .net對應。See "Declaring types in Windows Runtime components" and "Passing Universal Windows Platform types to managed code" in Windows Runtime components with C# and Visual Basic, and .NET mappings of Windows Runtime types.

其中有許多對應都是介面。Many of these mappings are interfaces. 例如,IList<T> 會對應至 UWP 介面 IVector<T>For example, IList<T> maps to the UWP interface IVector<T>. 若您使用 List<string> (在 Visual Basic 中為 List(Of String)),而非使用 IList <string> 做為參數類型,則 Winmdexp.exe 會提供包含所有由 List<T> 實作之對應介面的替代項目清單。If you use List<string> (List(Of String) in Visual Basic) instead of IList<string> as a parameter type, Winmdexp.exe provides a list of alternatives that includes all the mapped interfaces implemented by List<T>. 若您使用 List<Dictionary<int, string>> 之類的巢狀泛型類型 (在 Visual Basic 中為 List(Of Dictionary(Of Integer, String))),則 Winmdexp.exe 會提供適用於各個巢狀層級的選項。If you use nested generic types, such as List<Dictionary<int, string>> (List(Of Dictionary(Of Integer, String)) in Visual Basic), Winmdexp.exe offers choices for each level of nesting. 這些清單可能會變得相當長。These lists can become quite long.

一般而言,最接近類型的介面就是最好的選擇。In general, the best choice is the interface that is closest to the type. 以 Dictionary<int, string> 為例,IDictionary<int, string> 最有可能是最佳選擇。For example, for Dictionary<int, string>, the best choice is most likely IDictionary<int, string>.

重要:JavaScript 會使用 Managed 類型實作之介面清單中第一個出現的介面。Important JavaScript uses the interface that appears first in the list of interfaces that a managed type implements. 例如,若您將 Dictionary<int, string> 傳回 JavaScript 程式碼,則無論您將哪個介面指定為傳回類型,其皆會顯示為 IDictionary<int, string>。For example, if you return Dictionary<int, string> to JavaScript code, it appears as IDictionary<int, string> no matter which interface you specify as the return type. 這表示,如果第一個介面不包含出現在後續介面上的成員,該成員即不會對 JavaScript 顯示。This means that if the first interface doesn't include a member that appears on later interfaces, that member isn't visible to JavaScript.

警告 如果 JavaScript 會使用您的元件,請避免使用非泛型 IListIEnumerable 介面。Caution Avoid using the non-generic IList and IEnumerable interfaces if your component will be used by JavaScript. 這兩個介面會分別對應至 IBindableVectorIBindableIteratorThese interfaces map to IBindableVector and IBindableIterator, respectively. 它們支援 XAML 控制項的繫結,且不會對 JavaScript 顯示。They support binding for XAML controls, and are invisible to JavaScript. JavaScript 會發出執行階段錯誤「函式 'X' 具有無效簽章,無法呼叫」。JavaScript issues the run-time error "The function 'X' has an invalid signature and cannot be called."

 

錯誤號碼Error number 訊息文字Message Text
WME1033WME1033 方法 ' {0} ' 具有 {1} 類型 ' ' 的參數 ' ' {2} 。Method '{0}' has parameter '{1}' of type '{2}'. '{2}' 不是有效的 Windows 執行階段參數類型。'{2}' is not a valid Windows Runtime parameter type.
WME1038WME1038 方法 ' {0} ' 在其簽章中具有類型 ' ' 的參數 {1} 。Method '{0}' has a parameter of type '{1}' in its signature. 雖然這種類型不是有效的 Windows 執行階段類型,但它實作了有效 Windows 執行階段類型的介面。Although this type is not a valid Windows Runtime type, it implements interfaces that are valid Windows Runtime types. 請考慮將方法簽章變更為使用下列其中一種類型:'{2}'。Consider changing the method signature to use one of the following types instead: '{2}'.
WME1039WME1039

方法 ' {0} ' 在其簽章中具有類型 ' ' 的參數 {1} 。Method '{0}' has a parameter of type '{1}' in its signature. 雖然這種泛型類型不是有效的 Windows 執行階段類型,但此類型或其泛型參數實作了有效 Windows 執行階段類型的介面。Although this generic type is not a valid Windows Runtime type, the type or its generic parameters implement interfaces that are valid Windows Runtime types. {2}{2}

> \*\*注意*\* {2}若為,Winmdexp.exe 會附加一份替代專案清單,例如「考慮將方法簽章中的類型 ' IReadOnlyList < ' 變更 > 為下列其中一種類型: ' system.object.. t a t t. t a t t.. t a t t.. t < > < > < r t '」 > 。 > \*\*Note** For {2}, Winmdexp.exe appends a list of alternatives, such as "Consider changing the type 'System.Collections.Generic.List<T>' in the method signature to one of the following types instead: 'System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T>, System.Collections.Generic.IEnumerable<T>'."
WME1040WME1040 方法 ' {0} ' 在其簽章中具有類型 ' ' 的參數 {1} 。Method '{0}' has a parameter of type '{1}' in its signature. 請勿使用 Managed 工作類型,應改用 Windows.Foundation.IAsyncAction、Windows.Foundation.IAsyncOperation,或其他 Windows 執行階段非同步介面其中之一。Instead of using a managed Task type, use Windows.Foundation.IAsyncAction, Windows.Foundation.IAsyncOperation, or one of the other Windows Runtime async interfaces. 標準的 .NET await 模式也適用於這些介面。The standard .NET await pattern also applies to these interfaces. 如需將 Managed 工作物件轉換成 Windows 執行階段非同步介面的詳細資訊,請參閱 System.Runtime.InteropServices.WindowsRuntime.AsyncInfo。Please see System.Runtime.InteropServices.WindowsRuntime.AsyncInfo for more information about converting managed task objects to Windows Runtime async interfaces.

 

結構中包含不允許的欄位類型Structures that contain fields of disallowed types

在 UWP 中,結構只能包含欄位,而且只有結構可以包含欄位。In the UWP, a structure can contain only fields, and only structures can contain fields. 這些欄位必須是公用的。Those fields must be public. 有效的欄位類型包括列舉、結構及基本類型。Valid field types include enumerations, structures, and primitive types.

錯誤號碼Error number 訊息文字Message Text
WME1060WME1060 結構 ' {0} ' 具有類型 ' ' 的欄位 ' ' {1} {2} 。Structure '{0}' has field '{1}' of type '{2}'. '{2}' 不是有效的 Windows 執行階段欄位類型。'{2}' is not a valid Windows Runtime field type. Windows 執行階段結構中的每個欄位只能是 UInt8、Int16、UInt16、Int32、UInt32、Int64、UInt64、Single、Double、Boolean、String、Enum,或本身是結構。Each field in a Windows Runtime structure can only be UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Boolean, String, Enum, or itself a structure.

 

成員簽章中的陣列限制Restrictions on arrays in member signatures

在 UWP 中,成員簽章中的陣列必須是下限為 0 (零) 的一維陣列。In the UWP, arrays in member signatures must be one-dimensional with a lower bound of 0 (zero). 不允許 myArray[][] 之類的巢狀陣列類型 (在 Visual Basic 中為 myArray()())。Nested array types such as myArray[][] (myArray()() in Visual Basic) are not allowed.

注意  這項限制不適用於您在內部執行時所使用的陣列。Note This restriction does not apply to arrays you use internally in your implementation.

 

錯誤號碼Error number 訊息文字Message Text
WME1034WME1034 方法 ' {0} ' 在其簽章中具有類型為 ' ' 的陣列 {1} ,且系結非零。Method '{0}' has an array of type '{1}' with non-zero lower bound in its signature. Windows 執行階段方法簽章中的陣列的下限必須是零。Arrays in Windows Runtime method signatures must have a lower bound of zero.
WME1035WME1035 方法 ' {0} ' 在其簽章中具有類型 ' ' 的多維度陣列 {1} 。Method '{0}' has a multi-dimensional array of type '{1}' in its signature. Windows 執行階段方法簽章中的陣列必須是一維陣列。Arrays in Windows Runtime method signatures must be one dimensional.
WME1036WME1036 方法 ' {0} ' 在其簽章中具有類型 ' ' 的嵌套陣列 {1} 。Method '{0}' has a nested array of type '{1}' in its signature. Windows 執行階段方法簽章中的陣列不能是巢狀陣列。Arrays in Windows Runtime method signatures cannot be nested.

 

陣列參數必須指定陣列的內容是否可讀取或寫入Array parameters must specify whether array contents are readable or writable

在 UWP 中,參數必須是唯讀或唯寫的。In the UWP, parameters must be read-only or write-only. 參數不可標示 ref (在 Visual Basic 中為不含 OutAttribute 屬性的 ByRef)。Parameters cannot be marked ref (ByRef without the OutAttribute attribute in Visual Basic). 這適用於陣列的內容,因此陣列參數必須指出陣列內容是否為唯讀或唯寫。This applies to the contents of arrays, so array parameters must indicate whether the array contents are read-only or write-only. 這項指示對於 out 參數是明確的 (在 Visual Basic 中為具有 OutAttribute 屬性的 ByRef 參數),但是以傳值方式傳遞的陣列參數 (在 Visual Basic 中為 ByVal) 則必須標示。The direction is clear for out parameters (ByRef parameter with the OutAttribute attribute in Visual Basic), but array parameters that are passed by value (ByVal in Visual Basic) must be marked. 請參閱將陣列傳遞到 Windows 執行階段元件See Passing arrays to a Windows Runtime Component.

錯誤號碼Error number 訊息文字Message Text
WME1101WME1101 方法 ' {0} ' 具有屬於陣列的參數 ' ', {1} 且具有 {2} 和 {3} 。Method '{0}' has parameter '{1}' which is an array, and which has both {2} and {3}. 在 Windows 執行階段中,內容陣列參數必須是可讀取或可寫入的。In the Windows Runtime, the contents array parameters must be either readable or writable. 請從 '{1}' 移除其中一個屬性。Please remove one of the attributes from '{1}'.
WME1102WME1102 方法 ' {0} ' 的輸出參數 ' {1} ' 是陣列,但具有 {2} 。Method '{0}' has an output parameter '{1}' which is an array, but which has {2}. 在 Windows 執行階段中,輸出陣列的內容是可寫入的。In the Windows Runtime, the contents of output arrays are writable. 請從 '{1}' 移除屬性。Please remove the attribute from '{1}'.
WME1103WME1103 方法 ' {0} ' 具有屬於陣列的參數 ' ' {1} ,其具有 System.runtime.interopservices.outattribute. InAttribute 或 System.runtime.interopservices.outattribute. OutAttribute 的參數。Method '{0}' has parameter '{1}' which is an array, and which has either a System.Runtime.InteropServices.InAttribute or a System.Runtime.InteropServices.OutAttribute. 在 Windows 執行階段中,陣列參數必須具有 {2} 或 {3}。In the Windows Runtime, array parameters must have either {2} or {3}. 請移除這些屬性,或視需要以適當的 Windows 執行階段屬性取代。Please remove these attributes or replace them with the appropriate Windows Runtime attribute if necessary.
WME1104WME1104 方法 ' {0} ' 有不是陣列的參數 ' ' {1} ,且具有 {2} 或 {3} 。Method '{0}' has parameter '{1}' which is not an array, and which has either a {2} or a {3}. Windows 執行階段不支援使用 {2} 或 {3} 標記非陣列參數。Windows Runtime does not support marking non-array parameters with {2} or {3}.
WME1105WME1105 方法 ' {0} ' 的參數 ' ' 具有 {1} System.runtime.interopservices.outattribute. InAttribute 或 System.runtime.interopservices.outattribute. OutAttribute。Method '{0}' has parameter '{1}' with a System.Runtime.InteropServices.InAttribute or System.Runtime.InteropServices.OutAttribute. Windows 執行階段不支援以 System.Runtime.InteropServices.InAttribute 或 System.Runtime.InteropServices.OutAttribute 標記參數。Windows Runtime does not support marking parameters with System.Runtime.InteropServices.InAttribute or System.Runtime.InteropServices.OutAttribute. 請考慮移除 System.Runtime.InteropServices.InAttribute,並改以 'out' 修飾詞取代 System.Runtime.InteropServices.OutAttribute。Please consider removing System.Runtime.InteropServices.InAttribute and replace System.Runtime.InteropServices.OutAttribute with 'out' modifier instead. 方法 ' {0} ' 的參數 ' ' 具有 {1} System.runtime.interopservices.outattribute. InAttribute 或 System.runtime.interopservices.outattribute. OutAttribute。Method '{0}' has parameter '{1}' with a System.Runtime.InteropServices.InAttribute or System.Runtime.InteropServices.OutAttribute. Windows 執行階段只支援以 System.Runtime.InteropServices.OutAttribute 標記 ByRef 參數,不支援這些屬性的其他用法。Windows Runtime only supports marking ByRef parameters with System.Runtime.InteropServices.OutAttribute, and does not support other usages of those attributes.
WME1106WME1106 方法 ' {0} ' 具有屬於陣列的參數 ' ' {1} 。Method '{0}' has parameter '{1}' which is an array. 在 Windows 執行階段中,陣列參數的內容必須是可讀取或可寫入的。In the Windows Runtime, the contents of array parameters must be either readable or writable. 請將 {2} 或 {3} 套用到 '{1}'。Please apply either {2} or {3} to '{1}'.

參數名稱為 "value" 的成員Member with a parameter named "value"

在 UWP 中,傳回值會視為輸出參數,且參數名稱必須是唯一的。In the UWP, return values are considered to be output parameters, and the names of parameters must be unique. 根據預設,Winmdexp.exe 會爲傳回值指定名稱 "value"。By default, Winmdexp.exe gives the return value the name "value". 如果您的方法有名稱為 "value" 的參數,就會發生 WME1092 錯誤。If your method has a parameter named "value", you will get error WME1092. 有兩種方式可以修正這種情形:There are two ways to correct this:

  • 使用 "value" 以外的名稱命名您的參數 (在屬性存取子中,則為 "returnValue" 以外的名稱)。Give your parameter a name other than "value" (in property accessors, a name other than "returnValue").

  • 使用 ReturnValueNameAttribute 屬性變更傳回值的名稱,如下所示:Use the ReturnValueNameAttribute attribute to change the name of the return value, as shown here:

    using System.Runtime.InteropServices;
    using System.Runtime.InteropServices.WindowsRuntime;
    
    [return: ReturnValueName("average")]
    public int GetAverage(out int lowValue, out int highValue)
    
    Imports System.Runtime.InteropServices
    Imports System.Runtime.InteropServices.WindowsRuntime
    
    Public Function GetAverage(<Out> ByRef lowValue As Integer, _
    <Out> ByRef highValue As Integer) As <ReturnValueName("average")> String
    

注意 如果您變更傳回值的名稱,而新的名稱與另一個參數的名稱發生衝突,就會收到錯誤 WME1091。Note If you change the name of the return value, and the new name collides with the name of another parameter, you will get error WME1091.

JavaScript 程式碼可依名稱存取方法的輸出參數,包括傳回值在內。JavaScript code can access the output parameters of a method by name, including the return value. 如需範例,請參閱 ReturnValueNameAttribute 屬性。For an example, see the ReturnValueNameAttribute attribute.

錯誤號碼Error number 訊息文字Message Text
WME1091WME1091 方法 ' { 0} ' 具有名為 ' 1} ' 的傳回值,與 { 參數名稱相同。The method '{0}' has the return value named '{1}' which is the same as a parameter name. Windows 執行階段方法參數和傳回值必須具有唯一的名稱。Windows Runtime method parameters and return value must have unique names.
WME1092WME1092 方法 ' { 0} ' 具有名為 ' 1} ' 的參數,與 { 預設傳回值名稱相同。The method '{0}' has a parameter named '{1}' which is the same as the default return value name. 請考慮使用不同的參數名稱,或使用 System.Runtime.InteropServices.WindowsRuntime.ReturnValueNameAttribute 明確指定傳回值的名稱。Consider using another name for the parameter or use the System.Runtime.InteropServices.WindowsRuntime.ReturnValueNameAttribute to explicitly specify the name of the return value.

注意 屬性存取子的預設名稱為 "returnValue",而其他所有方法的預設名稱為 "value"。Note The default name is "returnValue" for property accessors and "value" for all other methods.