0

WCF アプリケーション内で OpenALPR を実行しようとしていますが、実行できません。私は得続けます

「ファイルまたはアセンブリ 'openalpr-net.DLL' またはその依存関係の 1 つを読み込めませんでした。指定されたモジュールが見つかりませんでした。」

IIS と VS2015-Community エディションの両方でエラーが発生しました。

次のスレッドに従いましたが、問題を解決できませんでした。

https://groups.google.com/forum/#!topic/openalpr/7ADDNSkhoLE
https://groups.google.com/forum/#!topic/openalpr/Nu26YmbOSng

インターネット全体で、それはプラットフォームの問題であると言われていますが、これは私が今持っているものです.

Visual Studio 2015 WCF Application
Reference to openalpr-net.dll (64bit) in my project
Copied opencv_world300.dll, opencv_ffmpeg300_64.dll, liblept170.dll into bin folder manually
Included openalpr.conf in the root folder of WCF application
Included runtime_data folder in the root folder of WCF application
Set 'unblock' for all the dll's, and files under runtime_data folder
Project > Properties > Build > General > Platform target > x64
Project > Properties > Build > Configuration > Active(Debug)
Project > Properties > Build > Platform > Active (x64)

また、アプリをローカルの iis サーバーに公開し、アプリケーション プールを .net 4.0 との統合モードに設定し、「32 ビット アプリケーションを有効にする」を有効または無効にしようとしましたが、どちらもうまくいきませんでした。

ソリューション エクスプローラーで Service.svc を選択してアプリをデバッグすると、WCF テスト クライアントで以下のエラーが発生します。

Error: Cannot obtain Metadata from http://localhost:55460/AlprService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:55460/AlprService.svc Metadata contains a reference that cannot be resolved: 'http://localhost:55460/AlprService.svc'. The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
Server Error in '/' Application.
Could not load file or assembly 'openalpr-net.DLL' or one of its dependencies. The specified module could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'openalpr-net.DLL' or one of its dependencies. The specified module could not be found.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FileNotFoundException: Could not load file or assembly 'openalpr-net.DLL' or one of its dependencies. The specified module could not be found.]   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +234   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +108   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +25   System.Reflection.Assembly.Load(String assemblyString) +34   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +49[ConfigurationErrorsException: Could not load file or assembly 'openalpr-net.DLL' or one of its dependencies. The specified module could not be found.]   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +772   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +259   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +163   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +230   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +76   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +139   System.Web.Compilation.BuildManager.ExecutePreAppStart() +176   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +882[HttpException (0x80004005): Could not load file or assembly 'openalpr-net.DLL' or one of its dependencies. The specified module could not be found.]   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +716

ダウンロード フォルダーの readme.txt ファイルから次のコマンドを問題なく実行でき、結果として「alpr -p tx -n 30 samples/us-4.jpg」が表示されます。

また、IIS で [32 ビット アプリケーションを有効にする] をオンにすると、projectname.dll が読み込まれていないというエラーが表示されます。Release - x64 を IIS に公開しています。

誰かが私を正しい方向に提案したり指摘したりできますか? ここで何が間違っていますか?

4

1 に答える 1

0

このまったく同じ質問に頭を悩ませていましたが、ついに機能しました。

64 ビットの openalpr-net.dll への参照を必ず追加してください。

WCF コードでは、このコードを使用して、アセンブリが存在する同じフォルダーから conf ファイルと runtime_data フォルダーを読み込んでいることを確認してください。

 public string AssemblyDirectory
    {
        get
        {
            var codeBase = Assembly.GetExecutingAssembly().CodeBase;
            var uri = new UriBuilder(codeBase);
            var path = Uri.UnescapeDataString(uri.Path);
            return Path.GetDirectoryName(path);
        }
   }
        String config_file = Path.Combine(AssemblyDirectory, "openalpr.conf");
        String runtime_data_dir = Path.Combine(AssemblyDirectory, "runtime_data");

        using (var alpr = new AlprNet("us", config_file, runtime_data_dir))

wcf をローカルまたはリモート IIS に公開します。c:\inetpub\wwwroot\alprService に公開するとします。openalpr.conf ファイルと runtime_data フォルダーを c:\inetpub\wwwroot\alprService\bin\ フォルダーにコピーします。liblept170.dll、opencv_ffmpeg300_64.dll、opencv_world300.dll の 3 つの dll をホスティング サーバーの system32 フォルダーにコピーします。これらの dll は、github の openalpr-net.dll と同じフォルダーにあります。

これがうまくいったかどうか教えてください。画像を送信して、一致するリストを取得できます。

これで、エラーなしで wcf サービスをロードできるはずです。

于 2016-08-23T13:57:45.927 に答える