Я получаю сообщение об ошибке при попытке загрузить библиотеку классов Visual C ++ CLR в Docker-контейнере - PullRequest
0 голосов
/ 26 сентября 2019

Цель: У меня есть несколько плоских библиотек Win32, для которых у меня нет исходного кода.

Я хочу сделать веб-сервис в контейнере Docker, который ссылается на этиdll's

Ожидаемый результат Когда я запускаю docker compose из Visual Studio, должен запускаться веб-сервис.

Фактический результат: Я получаю ошибкусообщение «Не удалось загрузить файл или сборку« ClassLibrary1 »или одну из ее зависимостей. Была предпринята попытка загрузить программу с неверным форматом». См. полное сообщение об ошибке ниже.

Вот шагиЯ прошел: Я установил Docker на свой ПК.В Visual Studio я создал новый проект типа веб-приложения ASP.NET (.NET Framework).В Visual Studio я добавил новый проект библиотеки классов CLR (Visual C ++).Я добавил ссылку на CLR-проект из проекта Web Application.В Visual Studio я нажал кнопку «Создать Docker».Появилось сообщение об ошибке ниже.Если я не сделаю ссылку на CLR-проект, я не получу сообщение об ошибке.

Надеюсь, вы мне поможете.Я и мой коллега потратили много времени, чтобы понять это.

С наилучшими пожеланиями, Питер Холк.

Полное сообщение об ошибке: Не удалось загрузить файл или сборку 'ClassLibrary1' или одну из ее зависимостей.Была предпринята попытка загрузить программу с неверным форматом.Описание: во время выполнения текущего веб-запроса произошло необработанное исключение.Пожалуйста, просмотрите трассировку стека для получения дополнительной информации об ошибке и ее возникновении в коде.

Сведения об исключении: System.BadImageFormatException: Не удалось загрузить файл или сборку 'ClassLibrary1' или одну из ее зависимостей.Предпринята попытка загрузить программу с неправильным форматом.

Ошибка источника:

 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.   

Assembly Load Trace: The following information can be helpful to determine why the assembly 'ClassLibrary1' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = ClassLibrary1
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: ClassLibrary1 | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/e22c2559/92c7e946/ClassLibrary1.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/e22c2559/92c7e946/ClassLibrary1/ClassLibrary1.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/bin/ClassLibrary1.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Трассировка стека:

[BadImageFormatException: Could not load file or assembly 'ClassLibrary1' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   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) +232
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +113
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +23
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +49

[ConfigurationErrorsException: Could not load file or assembly 'ClassLibrary1' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +762
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +259
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +167
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +238
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +78
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +334
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +178
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +746

[HttpException (0x80004005): Could not load file or assembly 'ClassLibrary1' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...