1

アンマネージ C++ コード (boost など) をラップするために、C++/CLI で DLL を作成しました。私がいる限り、これはかなりうまくいきます

  • 依存するすべての DLL を 1 つのフォルダーに入れ、
  • %PATH%環境を介してそのフォルダーを IIS に伝達します (システムの再起動が必要です)。

binただし、Microsoft は、アプリケーション パスの下のディレクトリ内にすべての依存関係を配置するだけで十分であると述べています。これは、次のように言うことで終わります。

Server Error in '/' Application.

Could not load file or assembly 'NETLibd.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 'NETLibd.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 'NETLibd.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, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'NETLibd.DLL' or one of its dependencies. The specified module could not be found.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677

[HttpException (0x80004005): Could not load file or assembly 'NETLibd.DLL' or one of its dependencies. The specified module could not be found.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090988
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Microsoftなどからの提案を見て、それに応じて調整しましweb.config。どちらも私にとってはうまくいきませんでした。

   <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <probing privatePath="/bin;bin/modules;/modules;\modules;bin\modules" />
            <dependentAssembly>
                <assemblyIdentity name="boost_chrono-vc100-mt-gd-1_52" publicKeyToken="0" culture="neutral" />
                <codeBase version="0.0.0.0" href="file:///C:/app/bin/modules/boost_chrono-vc100-mt-gd-1_52.dll" />
            </dependentAssembly>
    </assemblyBinding>
   </runtime>

このアプリケーション専用の特定のパスを IIS に伝える可能性はありますかweb.config? 実稼働システムでは、これらすべてのライブラリをシステム全体で利用できるようにすることはあまり賢明ではないと思い%PATH%ます。少なくとも、どの DLL が見つからなかったのかは興味深いでしょう (依存関係ウォーカーについては知っていますが、すべての DLL が同じディレクトリにあるため、欠落しているファイルについて文句を言うことはありません)。

4

1 に答える 1