【发布时间】:2015-03-18 16:51:10
【问题描述】:
我想从扫描仪获取图像。我有一个简单的 Java 应用程序,但我发现不存在直接从扫描仪获取图像的免费库。所以我有了这个想法,我在 C# 中创建了一个简单的项目来获取图像,他们从 java 应用程序调用这个 exe 文件。所以我在codesource上找到了这段代码。
http://www.codeproject.com/Articles/1376/NET-TWAIN-image-scanner
如果我尝试运行演示应用程序,它发现我可以从扫描仪获取图像。但是如果我尝试运行代码项目,我会遇到这个错误
System.DllNotFoundException non è stata gestita
IsTransient=false
Message=Impossibile caricare la DLL 'twain_32.dll': Routine di inizializzazione della libreria di collegamento dinamico (DLL) non riuscita. (Eccezione da HRESULT: 0x8007045A).
Source=TwainGui
TypeName=""
StackTrace:
in TwainLib.Twain.DSMparent(TwIdentity origin, IntPtr zeroptr, TwDG dg, TwDAT dat, TwMSG msg, IntPtr& refptr)
in TwainLib.Twain.Init(IntPtr hwndp) in c:\Users\michele.castriotta\Downloads\twaingui_src\TwainGui\TwainLib.cs:riga 58
in TwainGui.MainFrame..ctor() in c:\Users\michele.castriotta\Downloads\twaingui_src\TwainGui\MainFrame.cs:riga 29
in TwainGui.MainFrame.Main() in c:\Users\michele.castriotta\Downloads\twaingui_src\TwainGui\MainFrame.cs:riga 234
in System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
in System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
in System.Threading.ThreadHelper.ThreadStart()
InnerException:
我已经用 Visual Studio 2013 打开了项目,然后我将框架版本设置为 2.0,并选择 x86 作为 CPU。
此时错误在 TwainLib.cs 类中
TwRC rc = DSMparent( appid, IntPtr.Zero, TwDG.Control, TwDAT.Parent, TwMSG.OpenDSM, ref hwndp );
我尝试将 twain_32.dll 直接复制到调试文件夹中,但错误是一样的。系统找不到库。哪里出错了?
如果有可能从另一种语言获取图像对我来说是一样的。
【问题讨论】: