2016-08-06 68 views
1
using System;  
using System.Collections; 
using System.Reflection; 
using System.Runtime.CompilerServices; 
using System.Runtime.InteropServices; 
using System.Runtime.InteropServices.CustomMarshalers; 

namespace mshtml 
{ 
    [DefaultMember("item"), CompilerGenerated, Guid("3050F21F-98B5-11CF-BB82-00AA00BDCE0B"), TypeIdentifier] 
    [ComImport] 
    public interface IHTMLElementCollection : IEnumerable 
    { 
     void _VtblGap1_3(); 
     [DispId(-4)] 
     [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(EnumeratorToEnumVariantMarshaler))] 
     IEnumerator GetEnumerator(); 
    } 
} 

上面的代碼中存在給了我以下錯誤:錯誤CS0234:類型或命名空間名稱「CustomMarshalers」不存在命名空間「System.Runtime.InteropServices」

Error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?)

Pleae告知如何固定?這是一個反編譯的代碼,我是C#的初學者。

+0

我只是將你的代碼複製粘貼到一個新的項目中,並且都很好。沒有錯誤。在你的項目中可能缺少一些DLL引用? –

+0

不確定,我錯過了什麼 – Web

+0

僅用於測試,只需創建一個新項目並將代碼複製粘貼到那裏。 –

回答

1

你必須包括CustomMarshalers.dll
例子:
添加使用Project參考 - >添加引用 - >瀏覽 - >轉到位置「C:\ WINDOWS \裝配\ GAC_32 \ CustomMarshalers \ 2.0.0.0 __b03f5f7f11d50a3a「 - >選擇CustomMarshalers.dll

相關問題