Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambiguous #ctor in VB.NET #146

Closed
landersohn opened this issue Jan 19, 2015 · 10 comments
Closed

ambiguous #ctor in VB.NET #146

landersohn opened this issue Jan 19, 2015 · 10 comments

Comments

@landersohn
Copy link

My VB.NET app does not compile with 2.1.1.1 wrapper. The error is that #ctor is ambiguous. I think VB.NET gets confused by the two overloaded constructors, one wants a string for a config file, the other wants a collection for a list of config files.

@charlesw
Copy link
Owner

Can you please include a copy of the error.

On Mon, Jan 19, 2015 at 11:21 AM, landersohn [email protected]
wrote:

My VB.NET app does not compile with 2.1.1.1 wrapper. The error is that
#ctor is ambiguous. I think VB.NET gets confused by the two overloaded
constructors, one wants a string for a config file, the other wants a
collection for a list of config files.


Reply to this email directly or view it on GitHub
#146.

@landersohn
Copy link
Author

C:\Users\andersl\Desktop\PicturePerfect.NET-trunk\frmMain.vb(4038) : error BC31429: '.ctor' is ambiguous because multiple kinds of members with this name exist in class 'Tesseract.

I googled this and it appears there are several components that show this kind of error under VB.NET
Run in VS 2010.

@charlesw
Copy link
Owner

Thanks, I'll have a look into this when I have the time.

Might not be until the weekend though. Sorry.

On Mon, Jan 19, 2015 at 12:56 PM, landersohn [email protected]
wrote:

C:\Users\andersl\Desktop\PicturePerfect.NET-trunk\frmMain.vb(4038) : error
BC31429: '.ctor' is ambiguous because multiple kinds of members with this
name exist in class 'Tesseract.

I googled this and it appears there are several components that show this
kind of error under VB.NET
Run in VS 2010.


Reply to this email directly or view it on GitHub
#146 (comment).

@landersohn
Copy link
Author

No problem, appreciate the quick response. BTW, I think that you are doing this project is pretty awesome.

@landersohn
Copy link
Author

I think the problem may be that the constructors that accept the config file(s) have this parameter as optional, so VB.NET can not always decide which one to call. removing the "=null" from the function prototype may just do the trick

@landersohn
Copy link
Author

I recompiled the wrapper, commenting out the constructors except the one with the collection argument. It compiles but now I get an exception at runtime that seems to be thrown by the leptonica dll, or more precisely when loading the lib

  •   ex  {"Exception has been thrown by the target of an invocation."}   System.Exception
    
  •   System.Reflection.TargetInvocationException {"Exception has been thrown by the target of an invocation."}   System.Reflection.TargetInvocationException
    StackTrace  "   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)  
                                at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)  
                                at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)  
                at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)  
                at System.Activator.CreateInstance(Type type, Object[] args)  
                at InteropDotNet.InteropRuntimeImplementer.CreateInstance[T]()  
                at Tesseract.Interop.LeptonicaApi.Initialize()  
                at Tesseract.Interop.TessApi.Initialize()  
                at Tesseract.Interop.TessApi.get_Native()  
                at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode, IEnumerable`1 configFiles)  
                at Picture_Perfect_Match.frmMain.ProcessImages() in C:\Users\andersl\Desktop\PicturePerfect.NET-trunk\frmMain.vb:line 4038" String
    

InnerException:

  •   System.Collections.Generic.KeyNotFoundException {"The given key was not present in the dictionary."}    System.Collections.Generic.KeyNotFoundException
    

    thrown my mscorlib

      StackTrace  "   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)     
                  at InteropDotNet.LibraryLoader.LoadLibrary(String fileName, String platformName)     
                  at InteropRuntimeImplementer.LeptonicaApiSignaturesInstance.LeptonicaApiSignaturesImplementation..ctor(LibraryLoader loader)"   String
    

@landersohn
Copy link
Author

The exception is the same as in #141. The dll is located in the same folder where my app resides which is also the current working folder.

@charlesw
Copy link
Owner

Hi, I've had a look at this and can't reproduce using vs2013. I think you're correct and it is related to the default constructor arguments. Can you post your code that calls the constructor?

BTW did you resolve your other issue with it not finding the dlls?

@landersohn
Copy link
Author

The constructor is simply:

TessEngine(currentThreadNumber) = New
TesseractEngine(strAppLocation,
tessPrefixStr(threadData(currentThreadNumber).camera),            
           
_tessEngineModeSelection(tessEngineModeIdx(threadData(currentThreadNumber).camera)),
Tesseract.PageSegMode.AutoOsd)

The values typically are

tessPrefixStr(threadData(currentThreadNumber).camera) =  "eng"
tessEngineModeSelection(tessEngineModeIdx(threadData(currentThreadNumber).camera))
= EngineMode.TesseractOnly


I resolved the other issue by going back to 1.0.12. That version
does not have the DLL finding problem. If I need more functionality,
I edit the code and build a new wrapper. In fact, I added Sauvola
binarization which in my app works much better than Otsu.


On 01/23/2015 08:41 PM, Charles Weld
  wrote:


  Hi, I've had a look at this and can't reproduce using vs2013. I
    think you're correct and it is related to the default
    constructor arguments. Can you post your code that calls the
    constructor?
  BTW did you resolve your other issue with it not finding the
    dlls?
  —
    Reply to this email directly or view
      it on GitHub.

@charlesw
Copy link
Owner

I've updated the constructor signatures, while maintaining backwards compatibility, and added support for Sauvola Binarization in the recently released version 2.2.0. Should hopefully nullify this issue, please reopen if it doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants