2016-06-08 13 views
2

에 복사 한 후에 만 ​​aC# .dll-project를 참조하는 Visual Studio 2015에서 웹 프로젝트를 빌드하려고합니다. dotnetWrapper "는 C# 프로젝트의"managedDllWrapper "에 대한 # 래퍼입니다. 여기에는 일부 타사 64 비트 원시 C++ .dll이 포함됩니다.Visual Studio 2015는 bin 폴더에 복사 한 후에도 외부 .dll을 찾지 못하지만 c : Windows

참조 된 프로젝트와 웹 프로젝트는 .Net Framework 4.6.1 및 x64에서 실행됩니다. VS2015는 iis express 64 비트를 사용합니다.

모든 것이 잘 컴파일됩니다.

Server Error in '/' Application.

Could not load file or assembly 'managedDllWrapper.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 'managedDllWrapper.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 'managedDllWrapper.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 'managedDllWrapper.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.<>c.b__143_0(AssemblyInfo ai) +29

System.Linq.d__16'2.MoveNext() +293

System.Linq.d__66'1.MoveNext() +100

System.Linq.d__63'1.MoveNext() +73

System.Web.UI.Util.GetTypeFromAssemblies(IEnumerable assemblies, String typeName, Boolean ignoreCase) +217

System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +266

System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type) +48

System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +17

System.Web.Configuration.HandlerFactoryCache..ctor(String type) +25

System.Web.HttpApplication.GetFactory(String type) +104

System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +262

System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137

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

: 나는 (녹색 시작 버튼을 누르면) VS2015의 로컬 웹 서버를 시작하면

, 나는 "managedDllWrapper.dll"또는 해당 종속성 중 하나를 발견 할 수 없다는 오류 메시지가 네이티브 dll (의존성)은 (수동으로 복사 된) 웹 프로젝트 bin 폴더에 있습니다.

기본 DLL을 C : \ Windows \ 폴더에 복사하면 웹 응용 프로그램이 부드럽고 잘 작동합니다. 어쨌든, 웹 응용 프로그램의 dll 검색 경로는 C : \ Windows \ 폴더 만 가리 키지 만 웹 응용 프로그램 실행 (bin) 폴더도 조사해야합니다.

웹 응용 프로그램을 수행하지 않지만 모든 dll이 포함 된 래퍼가 포함 된 C# 콘솔 테스트 응용 프로그램을 실행하면 dll을 test-app bin 폴더에 복사하면 제대로 작동하고 응용 프로그램이 실행됩니다 . 웹 응용 프로그램 만 bin 폴더의 dll을 수락하지 않고이 문제가 발생합니다. 나는 C에 DLL을 복사 할 때

또한

는 : \ WINDOWS \ 디렉토리, 다시 DLL을 삭제하려고 다음 웹 응용 프로그램을 실행하고, 그들이 삭제 될 수 없다고

because the file is open in IIS Express Worker Process.

때문에 그래서, 아마도 IIS의 문제이고 VS2015의 문제는 아닙니다.하지만 IIS를 구성 할 수 없거나 어떻게해야할지 모르겠습니다. bin 폴더 (시도에

  • 복사 DLL을하지만, 상술 한 바와 만의 작품으로 작동하지 않습니다 나는 IIS가 구글과 유래에 내 모든 조사 결과 2015 년

    비주얼 스튜디오와 함께 제공되는 표현 사용 C# 콘솔 앱은 아니지만 웹 앱은 제외). :) 가능

    "[..].dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."

  • 확인 모든 64 비트 인 경우와 같은 닷넷 버전이 아닌 프로젝트 (에서 직접
  • 참조 DLL은 (64 비트, 닷넷 4.6.1 검사 항목 :. 그것을 잘 작동합니다 콘솔 앱은 아니지만 웹 앱은 제외).
  • .dll 폴더를 추가하려면 web.config를 변경하십시오. 그러나 이것은 도움이되지 못했습니다.

내 웹 프로젝트에서 C : \ Windows \ 이외의 다른 폴더에서 .dll을 찾을 수 있다면 행복 할 것입니다. 그 이유는 17 .dll을 C : 사이트를 게시하려면 MS azurewebsites의 Windows \ 폴더에 있습니다. 그런 다음 경로가 응용 프로그램 폴더 내에 있어야합니다.

+1

전역 어셈블리 캐시 ('gacutil/i')에 넣는 것이 C : \ Windows보다 낫지 만, 그 반대의 주장을 기억하지 못합니다. IIS 케이스를 해결할 수 있어야합니다. – Rup

+1

실제로 이것을 C# 프로젝트의 참조로 추가 했습니까? 그렇다면 참조의'Properties'에서'Copy Local'을 true로 설정하고 올바르게 참조하는지보십시오. – pay

+1

fuslogvw.exe를 사용해보아야합니다. Visual Studio 명령 프롬프트를 관리 사용자로 시작한 다음 fuslogvw.exe를 실행합니다. 로그 파일을 생성하도록 도구를 구성한 다음 다시로드를 시도하십시오. Fuslogvw.exe가 이제 어셈블리를로드 할 수없는 이유를 설명하는 로그 파일을 생성합니다. 이 도구는 이러한 문제에 매우 유용합니다. –

답변

0

나는 문제 1-1가 해결되지 않는,하지만 성공적으로 문제를 피할 : 명시 적으로 같이 DllImport와는 C#/C++ 래퍼를 다시 작성하여

를, 내가 직접 경로로 dll 파일을 따르기는 하겠지만. 그런 다음 종속 dll은 참조 된 dll과 동일한 폴더에 있어야합니다.이 기능은 웹 앱에서도 작동합니다.