Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:15:19+00:00 2026-06-01T17:15:19+00:00

I’ve got a working MonoTouch binding for ZBar up and running, but am having

  • 0

I’ve got a working MonoTouch binding for ZBar up and running, but am having troubles exposing a constant NSString that the Obj-C library defines for use as a Key in an NSDictionary:

inside ZBarReaderController.h:

extern NSString* const ZBarReaderControllerResults;  

I first tried via the actual MonoTouch binding as documented here:

[Static]
interface ZBarSDK
{
    [Field ("ZBarReaderControllerResults")]
    NSString BarcodeResultsKey { get; }
}

Attempting to build the project containing this gave these errors from btouch:

Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: startIndex
at System.String.Substring (Int32 startIndex) [0x00000] in :0
at Generator.Generate (System.Type type) [0x00000] in :0
at Generator.Go () [0x00000] in :0
at BindingTouch.Main (System.String[] args) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: startIndex
at System.String.Substring (Int32 startIndex) [0x00000] in :0
at Generator.Generate (System.Type type) [0x00000] in :0
at Generator.Go () [0x00000] in :0
at BindingTouch.Main (System.String[] args) [0x00000] in :0

I next attempted to manually call into the code as suggested in this other SO answer.

public static NSString BarcodeResultsKey
{
    get
    {
        var libHandle = Dlfcn.dlopen("libzbar.a",0);
        // I also tried this with "__Internal", rather than "libzbar.a"
        return Dlfcn.GetStringConstant(libHandle, "ZBarReaderControllerResults");
    }
}

It builds and executes fine, but just returns an empty string (as the Dlfcn.GetStringConstant documents it will do if it fails to link).

So, anyone else accessed const strings from a 3rd party Obj-C library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:15:20+00:00Added an answer on June 1, 2026 at 5:15 pm

    The generator, btouch, had a limitation (before 5.2.11) for [Field] bindings that requires the namespace to start with MonoTouch..

    A quick workaround for this issue is to rename the namespaces from ZBar to MonoTouch.ZBar and the binding definitions will build correctly.

    Since iOS applications must link with static libraries (.a) for libraries that are included with an application it’s also required to supply a library name "__Internal" in the bindings as described in the documentation.

    [Static]
    interface ZBarSDK {
        [Field ("ZBarReaderControllerResults", "__Internal")]
        NSString BarcodeResultsKey { get; }
    }
    

    There was also a compilation issue (on the generated code) which required some manual adjustment for the library (i.e. you can use null instead of the library name since it’s linked inside the main app). This is also fixed in the MonoTouch 5.2.11 release.

    With the workarounds (or MonoTouch 5.2.11) and the __Internal change you should be able to use [Field] inside your bindings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.