2016-06-28 52 views
0

我想在我的WCF應用程序中運行OpenALPR,並且遠不能運行它。我一直收到無法在WCF應用程序內部加載OpenALPR

「無法加載文件或程序集」openalpr-net.DLL「或其某個依賴項,找不到指定的模塊。

在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位應用程序」,但是這兩種沒的」爲我工作。

當我在Solution Explorer中選擇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沒有加載,其他這將是'openalpr-net.DLL'不會丟失。我將Release-x64發佈到IIS。

任何人都可以建議或指出我在正確的方向嗎?我在這裏做錯了什麼?

回答

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 \文件夾中。將3個DLL,liblept170.dll,opencv_ffmpeg300_64.dll和opencv_world300.dll複製到託管服務器上的system32文件夾中。你會在github的openalpr-net.dll文件夾中找到這些dll。

讓我知道這是否適合你。我能夠發送圖像並獲得一個匹配列表。

現在您應該可以在不出錯的情況下加載wcf服務。

相關問題