Application Runs when Debugging but not when Published - c#

When publishing my web application and then running it will return the error
"Could not load file or assembly 'BaseApplicationName' or one of its dependencies. An attempt was made to load a program with an incorrect format."
However if I run the application through debugging (f5) it runs correctly.
I guess what it comes down to is
what differences are there when running an application through debugging vs publishing it that would cause a problem like this?
When publising I have it set to delete all existing.
History of how it started... I added the 32 bit Oracle.DataAccess dll to my 64 bit system. It would not work and crash giving the same error as above but with the Oracle.DataAccess name instead of the baseApplicationName. I have since removed all references to it and removed the dll to try and get it to run without it once again.
Any advice?

You have a mismatch in your solution where you are mixing x86 with x64, the incorrect format message refers to trying to load a 64 bit dll from a 32 bit executable or vice versa.

Have you tried to "Clean" your solution and then rebuild it?

I am not sure which version of VS you are using - but I have noticed in 2005 and 2008 problems with it hanging on to dependencies that are not longer used. It might still be referencing the Oracle DLL during the publication step, and a bitness problem (32 vs 64) would give the error you see.
If you can't see any reference to the Oracle file in VS I would open the *proj file in notepad and see if there is a hidden reference to it that might be pushed to the server when you publish.
HTH

Related

System.Exception: 'Error loading msvcr120.dll (ErrorCode: 193)'

my system is windows 64 bit.
my projects runs on visual studio 2022. C#, .NET Framework 4.8 MVC.
when I try to run the program, I get this error:
System.Exception: 'Error loading msvcr120.dll (ErrorCode: 193)'
I read all kinds of documents I found about this error, talking about a 32 bit system/program that is not compatible with running on 64-bit operating system.
This is strange, because I have another computer where this error is not received, also 64-bit, and I copied the dll file from it.
(the project is exact same project).
I set the file as shown:
Does anyone have any idea what could be causing this error?
For now the problem is solved, in a very strange way!
I tried to update the Microsodt.SqlServer.Types package on the Nuget to the last version - and I get an error from the code.
so I downgrade the version, and now the error no longer appear.
if it help anyone in the future - the update version I currently have is:
Microsoft.SqlServer.Types: 14.0.1016.290

Could not load file or assembly 'myApp.Web' or one of its dependencies. An attempt was made to load a program with an incorrect format

I have web application which works fine when I have configuration in Visual studio:
"Active solution configuration. Debug, platform x86."
When I publish application with release configuration(Any CPU), I get the following error on publish server:
Could not load file or assembly 'myApp.Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.
If I change in visual studio to:
Active solution configuration, Release, platform x86.
and rebuild my application, I get the same error also on my computer.
If I change back to debug and rebuild, it works again.
I'm using Local IIS .
What could be wrong, I have tried every suggestion I have found but with no success?
Was having same problem. This problem comes out when you are using assemblies built for x86 or x64 explicitly. Make sure that all projects, especially if you are using native code somethere in satelite assemblies are set to be built for same platform in configuration manager.
update
It smells like your server and your build machine has different bitness. If you have same bitness set for debug and release and one is working while other is not it might be because of some settings miss in assembly publish process (release does not copy something or copies something wrong)

A dependent dll was not found

My app does not run on "Release x86" when running the app it crashes immediately after the splash screen. Output shows the following exception:
The program '[8204] dfz.exe' has exited with code -1073741515 (0xc0000135) 'A dependent DLL was not found'.
It also tells me the module is build without symbols, however in build settings I have set debug info to Full.
The first time I build the app for the Windows Store it built correctly and I also published that version to the store. When I did a manual rebuild to check if ads where inserted correctly it would not run.
However, I can run the app on ARM and X64 with no problems on release. Only x86 with .Net native toolchain will throw the missing dependant DLL.
What I have tried so far:
Created a new project, Added all my files and Nuget packages, No dice
Removed and updated all my existing references.
Tried to debug the release version so i can find out what DLL is missing from the package. However it keeps telling me there are no symbol files.
I am looking for any suggestions I can try because I am really at a loss here of why it will not run on x86.
Edit:
A blank UWP project also returns the DLL error when i run it. It looks like i have a broken development environment.
Edit2:
Just did a remote debugging session to another laptop and the app worked with no problems. So the problem is an environment related issue.
Could one of the projects in your dependencies be configured specifically for x64?
Another thing to check is that one of your projects is not set to build for that configuration (I vaguely remember some problem I had years ago that sounds kind like your situation ... although not for windows store apps ... and it turned out one of my projects wasn't set to compile for the configuration I was selecting ).

How to Deploy c# project with all dependencies in visual studio 2012

I have created a small c# program in visual studio 2012, I used two external dll libraries. When I build the project for release, it creates the release file with a bunch of other files, including the external dll's I used. It works on my computer, but if I copy that whole release file to another computer it just gives me an error message and exits.
What else does the program need to run?
The error message is:
The application was unable to start correctly(0x000007b). click OK to close the application.
I suspect that your error code is actually 0xC000007B (STATUS_INVALID_IMAGE_FORMAT), rather than 0x0000007B (INACCESSIBLE_BOOT_DEVICE). The former is common when your application encounters a runtime mixup between the 32 and 64 bit versions of a DLL.
What could be happening is that your application (say it's 32 bit) has a dependency on a certain DLL, call it FOO.DLL. When run on your local machine, you are picking up the correct version of the 32 bit version of FOO.DLL on your path. But when you deploy to the other machine, you are picking up a 64 bit version from somewhere on the system path. The INVALID_IMAGE_FORMAT error is thrown when the loader finds a 64 bit DLL trying to be loaded into your 32 bit app.
One way to fix this is by identifying the DLL and redistributing the correct version with your application.

Debugging x86 .NET application on Windows x64 in VS2008

I use the x64 version of Windows 7. My application use some COM servers (usual native x86 COM Servers) that can't be loaded in x64 context. So I decided run it as a x86 application using WOW so I set platform target as x86.
But Visual Studio 2008 debugger started to show messages like "The source file is different...." for all source files when I try debug it. What is reason for this behaviour? This question was born there "The source file is different...." message in Visual Studio 2008 is result of debugging x32 apps on x64 Windows
Update: I cleaned solution, rebuilt solution, removed obj, bin and etc. folders, restarted computer, reinstalled Visual Studio... So, what else could be the problem?
Update2: If you create new Windows Application project and change target platform to x86 you will see this trouble. But if you delete Settings1.settings from project the trouble will be eliminated!!. Any Idea?
Update3: http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/bc297668-65b4-46e8-969e-c7a6340d33b6
The error message you are getting is unrelated to debugging a WOW64 bit application. It's even less of an issue here because Visual Studio runs a 32 bit process inside of WOW64. So instead of x64 -> x86 you are actually doing an x86 -> x86 debugging session.
What's going on here is that Visual Studio is reading the checksum for the source files out of the PDB and it does not match the checksum of the files you are using to debug the application. The most likely causes for this are
Out of date PDB's
Using the incorrect source files. This is more common than you think in branching scenarios where you could easily grab the wrong version of the file.
The way I typically debug through this is
Close VS and manually delete all of the binaries and binary directories
Restart VS and rebuild
Close VS
Restart VS and attach to the running project without opening the solution
Then manually open the files
Windows 7 sets Windows Xp sp 3 compatibility mode for VS 2008 by default. Changing compatibility to Windows Vista SP2 mode have solved trouble.
You might also check the x86 build type. When you created it you may not of copied the settings from the default build and as such none of your code is building when you run your application.
Bring up the Solution Properties and check the Configuration Properties\Configuration page. Then make sure all of the projects are checked under Build for the Config/Platform combo you are using.

Categories

Resources