"WireUpCoreRuntime" tasks fails unexpectedly with a System.BadImageFormatException - c#

I am having trouble with a MSBuild 14.0 issue. I am creating a UWP/x64 Application (we have written the source to be able to run on Windows 8.x, Windows 10 and now Windows 10 Mobile. My current environment is VS 2015 update 1 running on Windows 8.1. My code exists on a TFS 2013 local server. I have a build controller and build agent installed from TFS 2015 running on a separate server (server 2012 R2) assigned to my XAML Build Definition. I can build locally on my server within a Visual Studio 2015 session. When I Queue a Build. I get the following error:
C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\Microsoft.Net.CoreRuntime.targets
(235): The "WireUpCoreRuntime" task failed unexpectedly.
System.BadImageFormatException: An attempt was made to load a program
with an incorrect format. (Exception from HRESULT: 0x8007000B) at
Microsoft.Build.Net.CoreRuntimeTask.WireUpCoreRuntime.CopyWin32Resources(String
lpPEFileToReadResourcesFrom, String lpPEFileToInsertResourcesInto)
at
Microsoft.Build.Net.CoreRuntimeTask.WireUpCoreRuntime.InternalExecute()
at Microsoft.Build.Net.CoreRuntimeTask.WireUpCoreRuntime.Execute()
at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at
Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
Initially I thought this was an environment issue with the build system not on a Windows 10 platform, however, if this was the case I would not be able to build locally in Visual Studio.
I have Disabled AV on my server for a build with no luck.
the build Configuration is x64/Release. I have also tried x64/Debug, ARM/Debug and ARM/Release. none of these build configurations work. I think it might have something to do with .NetNative but I cannot be certain.

This error usually occurs when the file image of a DLL or executable program is invalid, check following things first:
Make sure that you are not using a component that was created with a
different version of the .NET Framework.
Make sure that the file
image is a valid managed assembly or module.
Detailed information: Troubleshooting Exceptions: System.BadImageFormatException

Related

Microsoft.WebApplication.targets was not found during web application build

When I develop a web application via Visual Studio 2013 (version 12.0.21005) and compile/build and run locally (Citrix Desktop) it works fine. However, when the same project is built in our BUILD server it fails with the following error.
"error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found."
Looking at the build server (under C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio folder) I can find that there are v10.0 and v14.0 installed.
What instructs the system to look for v11.0 when other versions are avaiable on the server. is there some setting on the csproj or the solution file (as my WindowsForms based projects compile fine in the BUILD server)
Unfortunately I do not have the rights to install MSBUID in either the Citrix Desktop or the Build Server
Logged into the servers to find the available build versions
Found the answer in the following post.
https://devblogs.microsoft.com/aspnet/visual-studio-project-compatibility-and-visualstudioversion/
Als refer to https://en.wikipedia.org/wiki/MSBuild for version history

Could not load file or assembly - not working on asp, works on desktop

While using a native dll dependency on a asp.net web project and debugging in VS2015 with IIS express I'm getting the dreaded:
Could not load file or assembly 'XXX.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 'XXX.DLL' or one of its dependencies. The specified module could not be found.
HOWEVER the same dependency works fine in a simple forms app on the same machine - hence I assume all the dependencies and co-dependencies are present
maybe you have some clues, how can this be?
What I already tried:
putting all the potential dependencies in the web project output folder
putting all the potential dependencies in the /system32/ path
putting all the potential dependencies in the /system32/inetsrv and /sysWOW64/inetsrv
installing c++ redistributables (2010, 2012, 2013)
I 'unblocked' the dlls as they "came from another computer" (CASpol)
dependency walker did not give any clear results
process monitor did not give any clear results
some details:
VS2015 Community, running on an Azure VM with Windows Server 2012 (test system), clean install
the app uses CGAL and BOOST libraries (c++).
'Dependency tree' is as follows: C# wrapper references a CLR C++ project which in turn references the native C++ (only this one uses CGAL/Boost);
The C# wrapper is then used in the forms app (works) or the asp.net web app (doesn't work);
Putting Cgal dlls (around 6 files) into the bin output folder was enough to run the forms app.
PS: of course on my 2 dev machines (Win 7, Win 10) the asp.net project works swimmingly - but these contain dedicated installs of the huge c++ references.
PPS: I currently really prefer to use iis express due to external reasons. I have to simulate deploying the app on a clean-ish Win10 laptop, in a dev environment, with minimal external installations
PPPS it seems the win10 dev machine isn't working after all - edit: this was the key clue, see my answer below and Ho do I reference native files in IIS express?
I'm a bit stuck right now, thanks.
Solution: on Win 10 I copied the dll output (\bin folder) into the Program Files (x86)\IIS Express folder (as I am using the 32-bit version).
Apparently, this wasn't needed on Win7 - I will have to investigate why
I found this solution in:
Ho do I reference native files in IIS express?
EDIT: another, more elegant (?) solution is to disable shadow-copying in web.config as in http://faithlife.codes/blog/2013/05/using-native-dlls-from-asp-net-apps/
"The simplest solution I’ve found is to turn off shadow copying, which causes the DLLs to be loaded directly from the bin directory.(...) Just add a hostingEnvironment element to your web.config:"
<configuration>
...
<system.web>
...
<hostingEnvironment shadowCopyBinAssemblies="false" />

Outlook 2010 Addin Build on VS2012 is not working after deploying

I created a Outlook 2010 Add-In in VS2012 . For creating a installer i used install shield. Installer got created successfully and is running fine on my (development) system. But the same addin throws a error on deploying it on another machine.
Error: Usual functionality of the add in are working but it throws a
error--- An attempt was made to load a program with an incorrect
format. (Exception from HRESULT: 0x8007000B)
Note: In my addin project i use a C++ dll for calling it's methods (through DLLImport). In my machine it works perfectly through the setup but in another machine it throws the error.
Some More Info : Both the system are 64 bit. The registry is getting created properly on target machine.
I have tried a lot but not able to find a result. Any help will be highly appreciated.

Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies

I have used Magick.NET which is a .NET wrapper for ImageMagick, and it throws the above error on a client machine. It works fine on my machine though. I have not installed ImageMagick so I simply can't understand what I need to do on a client machine. I have VS 2012 installed.
Also, Magick.NET includes ImageMagick within it, I think it uses C++/CLI and exposes a .NET interface to the native ImageMagick, all within a single DLL. So what DLL does it need?
(I just came across this error so posting the solution I found.)
Magick.NET needs the VC 2012 Runtime installed, and Magick.NET V7+ (.NET 4.0) needs 2012 and the VC 2015 Runtime installed. Download and install on client machine. If it pops up a "repair or uninstall" dialog then its already installed and you might be missing another dependency. If not, install VCR and restart your app.
For me one more thing was needed:
in IIS Application pool -> advanced settings ->
Enable 32-Bit applications
I have error
System.TypeInitializationException: The type initializer for 'X86' threw an exception. --->
System.DllNotFoundException: Unable to load DLL 'Magick.NET-Q16-x86.Native.dll': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Fix by set Application pool -> advanced settings -> Enable 32-Bit = false

c#.net 32 bit application Not working on 64 bit OS

I am new to .NET application.
I have developed the application on 32 bit OS with Visual Studio 2008.
The application required the Microsoft.Interop services and for PDF services to open PDF files and MS Office files.
It also required SQL Express for database operations.
The application works fine on 32bit OS.
Then I created the setup for 64 bit OS, I added a new Setup project with wizard in Visual
Studio 2010 and select the Primary output and Localized resources.
But it does not included the Resources folder to the Application folder.
I set the target machine 64x and build the project, also before building give the prerequisites to the project which is Windows Installer 3.1, and .net framework 4.0, I have used the .net framwork 3.5 in the application.
Then I ran the setup, which executed successfully.
But when I tried to run the application it gave the message "Application has stoped working. Finding for the solution from the web.." and it closed.
Then I saw that there was no resources folder so I just copied the resources folder to the application where it was installed. Then the application worked fine.
So I created the setup again but this time I also provided the Resources folder to the application folder. Built the Setup and tried to run the application but the same message is prompted to me as it was giving before "Application has stopped working...", so I looked for the resource folder and all the required files which were there.
Creating a separate 64-bit version makes no sense in your case.
You have dependencies to 32-bit components; as a consequence, all1 your assemblies must be compiled to the x86 target platform and be installed using a 32-bit MSI.
If you get an "Application has stopped working..." error, this indicates that an exception occurred that has not been handled by your process. You can get the stack trace e.g. from the event log.
1 In fact, at the least the entry assembly must have an x86 target platform, and all other assemblies must have either an x86 or AnyCPU target platform.
Check you have changed the platform target to x64 or AnyCPU in your project -> Build Properties
hey friends thanks for answering my question. Finally doing a lot of things I found that it was converting the sql database to 2008 while creating the setup. And I was setting the sql express 2005 on the client machine. Then I changed the sql server 2005 to sql express 2008 and run the setup. Then I found that at the first time the exe required all the rights to convert so I tried the setup Run as Administrator and bingo the setup works for 2 different pc..
The only thing is required that at first time I need to run the application as Administrator.
Thanks for help I

Categories

Resources