Closed EugeneQilo closed 2 years ago
Hello, @EugeneQilo Thanks for your feedback. Saraff.Twain.Aux for .NET Core is posible, but it requareы refactoring. I can try to do it, but it will take some time.
@saraff-9EB1047A4BEB4cef8506B29BA325BD5A I think it will be a great to have it. How long you think it will take? I think the outproc approach is the best one, because it handles both 32bit and 64bit at the same time
Hello, @EugeneQilo See https://www.nuget.org/packages/Saraff.Twain.Aux/1.0.4.744
@saraff-9EB1047A4BEB4cef8506B29BA325BD5A thank you for putting effort into porting for .NET Core, I'm able to fetch Datasources for both 64Bit and 32Bit... But I'm getting the following errors when acquiring an image... I'm using Windows 11
For 32Bit
System.ArgumentException
HResult=0x80070057
Message=Cannot bind to the target method because its signature is not compatible with that of the delegate type.
Source=System.Private.CoreLib
StackTrace:
at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure)
at Saraff.Twain.Aux.Twain32RealProxy._FireEvent(EventHandlerTwainCommand obj)
at Saraff.Twain.Aux.TwainExternalProcess.AuxProcess._OnEvent()
at Saraff.Twain.Aux.TwainExternalProcess.AuxProcess.Execute(TwainCommand command)
at Saraff.Twain.Aux.Twain32RealProxy.Invoke(MethodInfo targetMethod, Object[] args)
at generatedProxy_1.Acquire()
at TwainSaraff.<>c__DisplayClass1_0.<Acquire>b__0(ITwain32 twain) in C:\dev\TwainSaraff.cs:line 121
at Saraff.Twain.Aux.TwainExternalProcess.Execute(String fileName, Action`2 execCallback)
For 64bit
System.InvalidOperationException
HResult=0x80131509
Message=Operation is not valid due to the current state of the object.
Source=Saraff.Twain.Aux
StackTrace:
at Saraff.Twain.Aux.Twain32RealProxy.Invoke(MethodInfo targetMethod, Object[] args)
at generatedProxy_1.Acquire()
at TwainSaraff.<>c__DisplayClass1_0.<Acquire>b__0(ITwain32 twain) in C:\dev\TwainSaraff.cs:line 121
at Saraff.Twain.Aux.TwainExternalProcess.Execute(String fileName, Action`2 execCallback)
at TwainSaraff.Acquire() in C:\dev\TwainSaraff.cs:line 74
Inner Exception 1:
InvalidOperationException: Operation is not valid due to the current state of the object.
Hello, @EugeneQilo It looks like your host process (Saraff.Twain.Aux_x86.exe or/and Saraff.Twain.Aux_MSIL.exe) is not rebuilt for .NET 6.0-windows
@saraff-9EB1047A4BEB4cef8506B29BA325BD5A They are compiled for .NET 6.0-windows, see below I'm calling them from build folder directly for testing
Do you have compiled exe files working?
Hello, @EugeneQilo Yes, I have compiled exe files working. The only problem that arises is the transfer of large images through native mode due to the buffer size limit. Try set the XFerMech to File or Memory.
TwainExternalProcess.Execute(
Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), Program._coreAux),
(twain, host) => {
try {
// ...
twain.Capabilities.XferMech.Set(TwSX.File);
twain.Capabilities.ImageFileFormat.Set(TwFF.Tiff);
twain.AcquireCompleted += Twain_AcquireCompleted;
twain.FileXferEvent += Twain_FileXferEvent;
twain.SetupFileXferEvent += Twain_SetupFileXferEvent;
twain.EndXfer += Twain_EndXfer;
twain.Acquire();
} catch(Exception ex) {
}
});
}
Hello,
First of all, I want to thank you for the great effort and information you have put online for free. I think a thank you is the least that I can do.
Secondly, I wanted to ask you if it is possible to use outproc method using Saraff.Twain.Aux but for .NET core... I'm currently using self-hosted WebApi and I'm running into the following error when calling Acquire
System.AccessViolationException HResult=0x80004003 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=
StackTrace: