Note that there are some explanatory texts on larger screens.

plurals
  1. POC# COM Object In VBA: Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic
    primarykey
    data
    text
    <p>Coming off of <a href="https://stackoverflow.com/questions/7012736/my-c-com-library-isnt-working-right-cant-instantiate-the-class-and-a-method-a">my other question</a> with a new problem: I get the titular error when attempting to access my X12Segment's Fields property.</p> <p>I came across <a href="https://stackoverflow.com/questions/3965767/function-or-interface-marked-as-restricted-or-the-function-uses-an-automation-ty">this question here</a> and took the initiative to get the IDL for my X12 type library. Also attached is the declaration of the Fields property in my interface, and its implementation; what's causing this error?</p> <pre class="lang-idl prettyprint-override"><code>// Generated .IDL file (by the OLE/COM Object Viewer) // // typelib filename: &lt;could not determine filename&gt; [ uuid(C0634D32-97A5-413A-8FC8-D6E0F4571F42), version(1.0), custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, "X12, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") ] library X12 { // TLib : // TLib : mscorlib.dll : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D} importlib("mscorlib.tlb"); // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb"); // Forward declare all types defined in this typelib interface IX12Segment; [ odl, uuid(28A76274-05EE-45B2-A8EF-ADD5A5B351DE), version(1.0), dual, oleautomation, custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "X12.IX12Segment") ] interface IX12Segment : IDispatch { [id(0x00000001), propget] HRESULT SegmentType([out, retval] BSTR* pRetVal); [id(0x00000001), propput] HRESULT SegmentType([in] BSTR pRetVal); [id(0x00000002), propget] HRESULT Fields([out, retval] SAFEARRAY(BSTR)* pRetVal); [id(0x00000002), propput] HRESULT Fields([in] SAFEARRAY(BSTR) pRetVal); [id(0x00000003), propget] HRESULT FieldDelimiter([out, retval] BSTR* pRetVal); [id(0x00000003), propput] HRESULT FieldDelimiter([in] BSTR pRetVal); [id(0x00000004), propget] HRESULT SegmentDelimiter([out, retval] BSTR* pRetVal); [id(0x00000004), propput] HRESULT SegmentDelimiter([in] BSTR pRetVal); [id(0x00000005), propget, custom(54FC8F55-38DE-4703-9C4E-250351302B1C, 1)] HRESULT ToString([out, retval] BSTR* pRetVal); [id(0x00000006)] HRESULT GetFieldEnum([out, retval] _Type** pRetVal); }; [ uuid(B321599A-E5EC-4510-A021-E9A8B4D6293E), version(1.0), custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "X12.X12Segment") ] coclass X12Segment { interface _Object; [default] interface IX12Segment; }; }; </code></pre> <pre class="lang-cs prettyprint-override"><code>[Guid("28A76274-05EE-45B2-A8EF-ADD5A5B351DE"), ComVisible(true)] public interface IX12Segment { //More stuff goes here [DispId(2)] string[] Fields { get; set; } //More stuff goes here } [Guid("B321599A-E5EC-4510-A021-E9A8B4D6293E"), ClassInterface(ClassInterfaceType.None), ComVisible(true)] public class X12Segment : IX12Segment { protected ArrayList _fields; protected short _minFields = -1; protected short _maxFields = -1; protected short[][] _fieldSizes = { new short[] { -1, -1 } }; //More stuff goes here /// &lt;summary&gt; /// Gets or sets all of the fields in the segment, /// in the form of an array of strings. /// &lt;/summary&gt; public string[] Fields { get { string[] o = new string[_fields.Count]; for (int i = 0; i &lt; o.Length; i++) { o[i] = _fields[i].ToString(); } return o; } set { ArrayList newFields = new ArrayList(value.Length); for (int i = 0; i &lt; value.Length; i++) if (_fieldSizes[0][0] == -1 || value[i].Length &lt;= _fieldSizes[i][1]) newFields.Add(value[i].ToCharArray()); else throw new Exception("Attempt to store a value longer than the possible field size: \"" + value[i] + "\" is larger than " + _fieldSizes[i] + " characters long."); } } //More stuff goes here } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload