2012-10-30 20 views
9

podczas debugowania w VS, błąd zostanie zgłoszony podczas uruchamiania debugowania w VS."Nie można załadować pliku lub zespołu lub jednej z jego zależności. Podjęto próbę załadowania programu o nieprawidłowym formacie."

Błąd znajduje się poniżej:

Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. 
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.BadImageFormatException: Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

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: 


[BadImageFormatException: Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0 
    System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43 
    System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127 
    System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142 
    System.Reflection.Assembly.Load(String assemblyString) +28 
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46 

[ConfigurationErrorsException: Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' 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) +613 
    System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203 
    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105 
    System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178 
    System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54 
    System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +232 
    System.Web.Compilation.BuildManager.CompileGlobalAsax() +51 
    System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337 

[HttpException (0x80004005): Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58 
    System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729 

[HttpException (0x80004005): Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8921851 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85 
    System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259 

Kiedy tworzę C# projektów, które wykorzystują „p4dn.dll” nie ma tego błędu napotykając.

To jest mój pierwszy projekt ASP, czytałem także podobne pytania, takie jak "http://stackoverflow.com/questions/41449/i-get-a-an-attempt-was-made-to-load-a -program-with-an-wrong-format-error-o "i" http://stackoverflow.com/questions/1648213/could-not-load-file-or-assembly-xxx-or-one-of-its -dependencies-an-attempt-was ". Nie mogą rozwiązać mojego problemu.

Jak mogę rozwiązać ten problem?

+0

sprawdzić, czy właściwości DLL w folderze projektu to Tylko do odczytu lub Nie. Jeśli jest to tylko do odczytu, odznacz to. –

+0

Sprawdziłem to i można go zapisywać. –

Odpowiedz

5

Miałem ten sam komunikat o błędzie, próbując uruchomić (debugować) 64-bitową witrynę MVC przy użyciu IIS Express 8.0. Potwierdziłem, że wszystkie moje projekty były ukierunkowane na platformę x64.

Wystąpił problem, ponieważ Visual Studio uruchamia 32-bitową wersję IIS Express. Jedyny sposób, w jaki mogłem go uruchomić, to uruchomić 64-bitowy program IIS Express, wykonując ręcznie następujące polecenie.

"C:\Program Files\IIS Express\iisexpress.exe" /config:"U:\IISExpress\config\applicationhost.config" /site:"Imaging.Web" /apppool:"Clr4IntegratedAppPool" 

Następnie w projekcie WWW Visual Studio przejdź do Właściwości, wybierz "Użyj niestandardowego serwera WWW" i wprowadź adres URL do swojej witryny.

Aby debugować, przejdź do debugowania> Dołącz do procesu ..., a następnie wybierz działającą instancję IIS Express.

Zespół Visual Studio naprawdę powinien ustawić tę opcję w oknie Właściwości projektu.

1

-create nową pulę IIS na swojej stronie internetowej -enable 32bit dla tej puli

9

Przejść do odpowiednich ==> Site Application Pool

Kliknij ==> Ustawienia Advance

 Change value of ==> "Enable 32-Bit Applications" from False to True 
+0

To zawsze była właściwa odpowiedź dla mnie, gdy uderzyłem w tę kwestię. –

+0

hah, właśnie miałem ten problem jeszcze raz, po raz kolejny go rozwiązałem, wróciłem do tego samego postu i próbowałem go powtórzyć, a potem zobaczyłem mój stary komentarz, wspomnienia ahhh :). –

+0

:) Tak, tak, to się zdarza, wracamy do tego samego problemu, a my szukamy i do niego przychodzimy. i powiedz hah ... ya, pamiętam. !! :) –

14

Istnieje teraz opcja menu do uruchomienia 64-bitowej wersji IIS Express. z menu Visual Studio wybierz Narzędzia -> Opcje ... -> projekty i rozwiązania -> Web Projects

Kliknąć przycisk "Użyj wersji 64 bitowej IIS Express, dla stron internetowych i projektów"

+1

Dlaczego tak trudno jest znaleźć ?! Z pewnością, jeśli wybierzesz 64-bitowe studio VS, powinno być wystarczająco inteligentne, aby to zrozumieć! – SlimCheney

+0

Nie takie mądre, to na pewno jest denerwujące! –

+0

Dzięki to zadziałało dla mnie. –

Powiązane problemy