Deployment optimization failed, how to fix? - c#

I am developing a windows phone app (The solution consist of two projects, i am referring one project in the other) with sqlite as the Database. The App runs only on the ARM platform. In Debug mode the app runs fine on the device and all functionalities of the app appears working but when i change it to Release mode i get the following error
Deployment optimization failed due to an invalid assembly. Rebuild
your source projects and try again.
I rebuild the project several time but getting the same error on Release mode. I found this and tried it but couldn't solve my issue., I also removed all the unused assemblies in my .cs files. how can i fix this ? what am i doing wrong ?

I finally found a solution !! In release mode i removed .dlls one by one and built the solution when error occurs i added them back. In my case the error was because of a dll from nuget , i fixed that and as next step i configured Debug Mode to be Simiar to Release mode by right clicking on the projects and selecting properties and then changing configurations same for both Debug and Release modes...

Related

Debug dll referenced by Xamarin.Forms project with VS 2019

I have a Xamarin.Forms project and referenced a dll, which I wrote. Don't know since when, but now I can't set a breakpoint in the dll or step into the dll. I'm debugging directly on an Android tablet.
First, I got the message
Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).
Then I changed the debug options and unchecked "Enable Just My Code". Now I get
No compatible code running
The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing).
I checked the solutions from this post, but up to now nothing of them worked:
pdb files are on the same place, where the dll is
"Enable Just My Code" was unchecked
everything in Debug mode under Build > Configuration Manager (Xamarin.Forms project as well as library)
uncheck of "Require source file exactly match with original Version" and "Step over Properties and Operators"
restart of VS
clean solutions and rebuild
clean of %USERPROFILE%\AppData\Local\Temp as described here
checked "Enable native code debugging" in the XF solution project options
restarted PC
removed app and support libraries from device
tried another device incl. emulator
It always worked like this:
checked reference to correct dll version (with rebuild)
open *.cs file from the dll project
set breakpoint or step into dll and have fun
Now it doesn't and I'm runnig out of ideas. I'm using Visual Studio 2019 (v 16.5.4). It does work with project reference, but I don't want to change the settings everytime. Or has this feature (debugging a referenced dll) been removed in VS 2019?
I ran into same error when implementning CrossMediaManager plugin, after seaching a lot, figured out that the instance should be initiated in the app constructor, i.e CrossMediaManager.Current.Init(); in the code sample below:
public App()
{
InitializeComponent();
DependencyService.Register<MockDataStore>();
CrossMediaManager.Current.Init();
MainPage = new Audio();
}

"Error while trying to run project: Unable to start program". Can run program only once. Then VS needs restart

I'm running my .NET 4.0 (C#) project in debug mode after I start VS2013. It runs just fine.
The second time I start it from VS, I get the Dialog box that says "Error while trying to run project: Unable to start program C:\path\to\file.exe"
The process is still alive in the Taskmanager when I dismiss the dialog box.
From Windows Explorer, I can run the program just fine. And after closing it, the process is gone too from the Task Manager.
A rebuild doesn't help.
Is this a common problem with a known solution?
I had an issue similar to this and I had to clear the component cache instruction can be found Here.
Hope this helps.
For my case, it cause by Platform target, you could force choose it to x86 or x64 which your project is:
Each Project's Properties > Build > Platform target
As I pointed out also here, the only solution that worked for me was to disable the ConEmu integration:
ConEmu &rightarrow; Settings &rightarrow; Integration &rightarrow; Default term &rightarrow; disable Force ConEmu as default terminal for console applications
Some users reported that it was enough for them to disable the Aggressive mode in that same settings tab; that wasn't the case for me though.
The topic is old, but this might help someone else.
So in my case I made a file in Visual Studio with .cp extension (accidentally deleted the last 'p') this made visual studio just "include" the the file and not mark it as a compilation unit, thus not compiling it, I looked the *.vcxproj file in a text editor and found out about this, so if you open the project file in a notepad or something just find your file at the bottom usually and change from <Item .../> to <ClCompile .../>
I was getting similar errors. I just had to restart visual studio. Sometime couple times a day.
I had a similar error and resolved it by cleaning the solution. Right-click the solution name in Solution Explorer and choose Clean Solution.
I found a solution here:
Please check "Use Managed Compatibility Mode" under Tools|->Options->Debugging->General.
I'm Brazilian, I don't speak English very well. I did this translation on google translator.
I know the topic is old, but it can still help someone.
I had this same problem in the following situation, I have a dual boot computer (linux debian 11 and windows 10). Inside debian, on my NTFS D disk, I created a folder to perform programming tests. After accessing that same folder with windows, I created a new project in visual studio inside that same folder that I had created in linux. The creation of the project went without problems, however when I tried to run the project (F5), I received the same error from this topic. I tried all the solutions I found on the internet, and nothing worked. I gave all permissions to my admin user and it still didn't work. Then I realized that even going straight to the folder where the application's executable was and clicking directly on it, I still received the access denied error message. So, I took the project out of the folder I had created in linux, and it worked. So, what I could conclude, is that because the folder where my project was was created in linux, for some reason, my windows didn't trust this folder, so it didn't allow running executables from inside that folder, even this one executable having been created by visual studio from within windows.
Just simply create a folder name as "projects" in c drive and copy paste the newly created project in it. Run the project by doing clean & Build or Rebuild method . It will work
open the folder which contains the solution in visual studio.
again, open your *.sln file by double clicking it inside the solution explore once opened try running the solution or rebuild the solution. once rebuild gets completed, it will open without error from next time.
My way of solving the error : error while trying to load project : Unable to start program and c:\Path\to\file.exe was simply by
First restart Visual Studio
Click the build icon
Select the rebuild option
Run the Program or Debug the Program
This was a weird one. Going to put what happened to me here because it might happen to someone else. Everything was fine with the app until suddenly after some fairly insignificant code changes I suddenly started getting this error. Visual Studio was compiling the executable just fine. But, the moment I tried to run it (either from Visual Studio or directly) the executable file would be automatically deleted right out of the Debug folder. Super odd--never seen anything like it. I began to get suspicious that perhaps an anti-virus or the OS was somehow identifying a checksum or some signature in the executable as "dangerous". Or perhaps some obscure compilation bug was corrupting the executable. So on a hunch I made another innocuous change (added a couple of lines of code to color code some text in a rich text box) and the problem went away.

No symbols have been loaded - windows service and topshelf

I am trying to debug a windows service. It's running as a console application with Topshelf. The startup project runs fine in with breakpoints and everything but none of the referenced projects in the solution seem to load their symbols. All the .pdb files are in the respective bin-folders. And a copy of all the referenced .pdb files are also in the startup projects bin-folder. Everything builds/rebuilds when i press F5.
It worked fine a few days ago and still works fine on all my colleagues PC's.
I'm sure I'm running all projects in debug mode.
I've cleaned, rebuilt and tried attaching to the process instead of just F5.
I get the same behavior in both VS2017 and VS2015.
I've deleted all the source code and redownloaded and even reinstalled all versions of VS.
None of the referenced projects show up in the Modules window. (* Actually. One of the referenced projects does show up sometimes, but I don't understand when/why. I can debug that project - when it shows up in the Modules window)
Disable the debug option Enable Just My Code (Tools -> Options)
Be advised; turning this off will slow down start up time of the debugger since loads of symbols will be loaded. It's best to debug the other assemblies in their original solution.
You can also do this, Start debugging, as soon as you've arrived at a breakpoint or used Debug > Break All. That's it

UWP app WACK test fails & outputs debug irrespective of chosen settings

I am trying to create a package of my UWP app and put it through a WACK test.
Windows App Certification Kit - Test Results is FAIL. I think it's because VS2015 is outputting a debug build irrespective of the settings i've chosen.
Has anyone come across this problem before?
Is visual studio ignoring my settings, or does my project include a library that's not going to pass WACK?
'Release' is selected both in the build menu and in Output Package dialogue.
JSON.net and EF7 only, both are UWP compatiable. Tasks and DataAccess are a background task and a class library.
File C:\Program Files\WindowsApps\f0679d56-bdc0-4305-837e-16b5560c7c41_1.0.14.0_x86__ade4xr40r36he\coreclr.dll has failed the AppContainerCheck check.
File C:\Program Files\WindowsApps\f0679d56-bdc0-4305-837e-16b5560c7c41_1.0.14.0_x86__ade4xr40r36he\dbgshim.dll has failed the AppContainerCheck check.
File C:\Program Files\WindowsApps\f0679d56-bdc0-4305-837e-16b5560c7c41_1.0.14.0_x86__ade4xr40r36he\mscordaccore.dll has failed the AppContainerCheck check.
File C:\Program Files\WindowsApps\f0679d56-bdc0-4305-837e-16b5560c7c41_1.0.14.0_x86__ade4xr40r36he\mscordbi.dll has failed the AppContainerCheck check.
i also have the same issue and it is caused due to EntityFreamework.Commands reference. When you building the code for store package or release mode just remove all references of EntityFramework.commands by uninstalling from nuget.
that should help to get rid of those errors. for more information please go here. let me know how it went.. all the best.
I am now using VS2015 preview 2 and everything is building with it just fine. I get no errors in the WACK.
Microsoft just decided to release .net native a year before it could actually compile things properly.

C# application throwing system.BadImageFormat exception. Dependencies compiled in x64

I have been trying to run the first skeleton program listed here:
https://sites.google.com/site/augmentedrealitytestingsite/download
I am using VS2010 express under Windows 7 64bit.
When I tried to build and run, it first threw:
"An attempt was made to load a program with an incorrect format"
Followed shortly by a System.BadImageFormatException due to calling a PInvoke method from the referenced ARTKPManagedWrapper.DLL.
I recompiled the reference on my PC but the problem persisted. I also tried to set the target platform to x86 (it is currently set on Any CPU) but there was no option other than Any CPU.
Does anyone have any idea what else could be going wrong here?
You have to create the option if it isn't there. I was able to get it to work by going into Build --> Configuration Mananger going into the Platform Column and creating an new x86 configuration.
If configuration manager is not visible to you. You will want to look at this Blog
From Blog:
First, select Tools|Options to bring up the Options dialog.
Make sure that "Show all Settings" in the bottom left-hand corner is set.
Select the Projects and Solutions page and set "Show Advanced build configurations."
and from the Comments
You've just got to ensure that Tools -> Settings -> Expert Settings is selected as well.
In IIS on the app pool for the website under the advanced settings change the following setting
Enable 32 bit applications to true.

Categories