# ROInvalidVariantCodeException

**URL:** https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110
**Category:** Remoting SDK
**Created:** [April 9, 2014, 2:57pm UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110 "2014-04-09T14:57:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![bobbywalkergoc](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bobbywalkergoc](https://talk.remobjects.com/u/bobbywalkergoc)
#### Post date: [April 9, 2014, 2:57pm UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/1 "2014-04-09T14:57:19Z")

</div>

We have created a service and it is apparently easy to use in .NET but I am having difficulty calling it within XCode. Here is the method I am trying call:

- (ROVariant\*)CreateJournal  
:(NSString\*)\_p\_JournalSubject  
:(NSData\*)\_p\_binRecipientList  
:(int32)\_p\_JournalSysCategoryid1  
:(int32)\_p\_JournalSysCategoryid2  
:(int32)\_p\_Userid  
:(int32)\_p\_Deptid  
:(int32)\_p\_Activityid  
:(NSString\*)\_p\_DeptDescription  
:(int32)\_p\_SecLevel  
:(NSString\*)\_p\_AttachedDocs  
:(NSString\*)\_p\_Priority  
:(NSString\*)\_p\_AssociatedActivity  
:(NSString\*)\_p\_JournalPerson  
:(NSString\*)\_p\_JournalDoc  
:(NSString\*)\_p\_JournalTransmission  
:(NSString\*)\_p\_JournalAssignment  
:(NSString\*)\_p\_JournalTag  
:(NSString\*)\_p\_JournalMemo  
:(NSString\*)\_p\_CreateUserFullname  
:(int32)\_p\_Macroid  
:(NSString\*)\_p\_sContext  
:(int32)\_p\_iDetail1  
:(int32)\_p\_iDetail2  
:(int32)\_p\_iDetail3  
:(int32)\_p\_iDetail4  
:(NSString\*)\_p\_sConcerning  
:(NSString\*)\_p\_sFaxCover  
:(BOOL)\_p\_bTransmit  
:(NSString\*)\_p\_JounalHeaderAccess  
:(ROVariant\*)\_p\_vParams  
:(NSData\*)\_p\_binDocumentList

And the error I’m getting when trying to do is:

\*\*\* Terminating app due to uncaught exception ‘ROException’, reason: ‘Invalid or unsupported variant type code’

Any help trying to figure this out would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![alexk](https://talk.remobjects.com/user_avatar/talk.remobjects.com/alexk/32/537_2.png) [@alexk](https://talk.remobjects.com/u/alexk)
#### Post date: [April 10, 2014, 7:56am UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/2 "2014-04-10T07:56:10Z")

</div>

Hello Bobby,

A Variant is a special general data type that can contain many different kinds of data.  
Particular type of the stored object is specified in type property of the ROVariant instance  
At the moment RO/Xcode supports following subtypes in the ROVariant:

varEmpty, varNull, varVariant, varArray  
varBoolean, varByte, varDateTime,varGuid, varBinary  
varInt8, varWord, varInt16, varLongWord, varInt32, varInt64  
varDecimal, varDouble, varCurrency  
varString, varDelphiString, varDelphiUtfString,

So can you look what exact subtype of the variant instances is used at your .NET part?  
(I’m seing that your method returns ROVariant and vParams also has ROVariant types)

Thanks!

---

<div class="post-metadata">

### Author: ![Will\_Honor](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@Will\_Honor](https://talk.remobjects.com/u/Will_Honor)
#### Post date: [April 10, 2014, 9:26am UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/3 "2014-04-10T09:26:02Z")

</div>

I have seen this error with a Delphi server and Android (Java) Client. For me, it happens when the Delphi server sends a value of varEmpty. RO Java has the following variant types declared in VariantType.pas

```
VariantTypeCode = public enum (
    varEmpty,
    varNull,
    varInt8,
    varInt32,
    varSingle,
    varDouble,
    varCurrency,
    varDateTime,
    varString,
    varDispatch,
    varError,
    varBoolean,
    varVariant,
    varUnknown,
    varDecimal,
    varInt16,
    varByte,
    varWord,
    varLongWord,
    varInt64,
    varGuid,
    varDelphiString,
    varDelphiUtfString,
    varArray, 
    varBinary
  );

```

Delphi can issue these types but the BinReaderWriter Method does not decode all of them.

```
method BinReaderWriter.readVariant(aValue: VariantType; aTypeCode: VariantTypeCode);
begin
  case aTypeCode of
    VariantTypeCode.varBoolean : aValue.AsBoolean := readBoolean;
    VariantTypeCode.varByte, VariantTypeCode.varInt8 : aValue.AsInt32 := readByte;
    VariantTypeCode.varDateTime : aValue.AsDate := readDateTime;
    VariantTypeCode.varDecimal : aValue.AsDecimal := readDecimalLittleEndian;
    VariantTypeCode.varDouble : aValue.AsDouble := readDoubleLittleEndian;
    VariantTypeCode.varCurrency : aValue.AsDecimal := readCurrencyLittleEndian;
    VariantTypeCode.varInt32, VariantTypeCode.varLongWord : aValue.AsInt32 := readInt32LittleEndian;
    VariantTypeCode.varInt64 : aValue.AsInt64 := readInt64LittleEndian;
    VariantTypeCode.varString, VariantTypeCode.varDelphiUtfString : aValue.AsUtfString := readUtf8String;
    VariantTypeCode.varDelphiString : aValue.AsString := readAnsiString;
    VariantTypeCode.varInt16, VariantTypeCode.varWord : aValue.AsInt32 := readSingleLittleEndian as Integer;
    VariantTypeCode.varNull : aValue.setNull;
    VariantTypeCode.varGuid : aValue.AsUuid := readGuid;
    else raise new Exception("BinReaderWriter : Unknown or unsupported variant type code");
  end;
end;

```

The most notable absence is varEmpty which in Delphi is the same as varUnassigned which is the default state for a variant. I think these values should be mapped properly even if the types have to be coalesced into something available on the target system.

Regards,  
Will.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [April 14, 2014, 11:06am UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/4 "2014-04-14T11:06:17Z")

</div>

Thanks, logged as bugs://67540: varEmpty isn’t supported

---

<div class="post-metadata">

### Author: ![Will\_Honor](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@Will\_Honor](https://talk.remobjects.com/u/Will_Honor)
#### Post date: [June 11, 2015, 11:58am UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/5 "2015-06-11T11:58:39Z")

</div>

Hello,  
Was bugs bugs://67540 ever fixed?

Regards,  
Will.

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [June 11, 2015, 2:16pm UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/6 "2015-06-11T14:16:58Z")

</div>

#67540 isn’t fixed yet.

---

<div class="post-metadata">

### Author: ![Will\_Honor](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@Will\_Honor](https://talk.remobjects.com/u/Will_Honor)
#### Post date: [June 11, 2015, 2:46pm UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/7 "2015-06-11T14:46:39Z")

</div>

That’s a shame. Delphi servers initialise Variant to varEmpty, which android clients then blow up on when they receive them.

My use of variants is to allow nullable types across the wire. I’m not keen on variant use as they are not typesafe. Does remobjects have any plans for nullable types across the wire? It is the only feature I really wish that you could add as its absence causes a lot of jumping through hoops to get the functionality.

Regards,  
Will.

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [June 12, 2015, 7:53am UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/8 "2015-06-12T07:53:38Z")

</div>

#67540 was logged as XCode issue. I’ll move it to Java category and re-review later

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [June 19, 2015, 11:11am UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/9 "2015-06-19T11:11:34Z")

</div>

bugs://67540 got closed with status fixed.

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [June 19, 2015, 11:12am UTC](https://talk.remobjects.com/t/roinvalidvariantcodeexception/4110/10 "2015-06-19T11:12:40Z")

</div>

as a workaround, add

```auto
    VariantTypeCode.varEmpty : aValue.setEmpty;

```

into that code
