A
alex
Hi,
I'm scratching my head trying to implement the AutoTextEntries interface (below)
The roadblock is implementing the indexer. Certainly, C# doesn't like the following piece throwing the compiler error
ref and out are not valid in this context (CS0631). Any suggestions how to overcome it?
public Word.AutoTextEntry this[ref object Index]
{
get
{
throw new NotImplementedException();
}
}
This is the interface:
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Word
{
[Guid("00020937-0000-0000-C000-000000000046"), TypeLibType(4288)]
[ComImport]
public interface AutoTextEntries : IEnumerable
{
[DispId(1000)]
Application Application
{
[DispId(1000)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
get;
}
[DispId(1001)]
int Creator
{
[DispId(1001)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
[DispId(1002)]
object Parent
{
[DispId(1002)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(1)]
int Count
{
[DispId(1)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
[DispId(0)]
AutoTextEntry this[[MarshalAs(UnmanagedType.Struct)] [In] ref object Index]
{
[DispId(0)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
get;
}
[DispId(-4), TypeLibFunc(1024)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")]
IEnumerator GetEnumerator();
[DispId(101)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
AutoTextEntry Add([MarshalAs(UnmanagedType.BStr)] [In] string Name, [MarshalAs(UnmanagedType.Interface)] [In] Range Range);
[DispId(102)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
AutoTextEntry AppendToSpike([MarshalAs(UnmanagedType.Interface)] [In] Range Range);
}
}
I'm scratching my head trying to implement the AutoTextEntries interface (below)
The roadblock is implementing the indexer. Certainly, C# doesn't like the following piece throwing the compiler error
ref and out are not valid in this context (CS0631). Any suggestions how to overcome it?
public Word.AutoTextEntry this[ref object Index]
{
get
{
throw new NotImplementedException();
}
}
This is the interface:
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Word
{
[Guid("00020937-0000-0000-C000-000000000046"), TypeLibType(4288)]
[ComImport]
public interface AutoTextEntries : IEnumerable
{
[DispId(1000)]
Application Application
{
[DispId(1000)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
get;
}
[DispId(1001)]
int Creator
{
[DispId(1001)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
[DispId(1002)]
object Parent
{
[DispId(1002)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(1)]
int Count
{
[DispId(1)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
[DispId(0)]
AutoTextEntry this[[MarshalAs(UnmanagedType.Struct)] [In] ref object Index]
{
[DispId(0)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
get;
}
[DispId(-4), TypeLibFunc(1024)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")]
IEnumerator GetEnumerator();
[DispId(101)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
AutoTextEntry Add([MarshalAs(UnmanagedType.BStr)] [In] string Name, [MarshalAs(UnmanagedType.Interface)] [In] Range Range);
[DispId(102)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Interface)]
AutoTextEntry AppendToSpike([MarshalAs(UnmanagedType.Interface)] [In] Range Range);
}
}