Could not load file or assembly '0 bytes loaded from System, Version=4.0.0.0 - visual-studio-2010

I got the following error when I am Building Solution for my app.
Could not load file or assembly '0 bytes loaded from System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Working in Microsoft Visual Studio 2010. Windows phone 7.1 Silverligt Application.
64-bit operating system.
Any help appreciated.

Appearantly, you are trying to load a DLL that is specifically for Windows 7/xp 64 bit into the phone7 OS. then you get this errormessage.

Related

How to solve BadImageFormatException error?

I am using Visual Studio 2012 and 64bit Oracle client installed on my computer(x64). I have added Oracle.DataAccess dll to my project references and getting this warning:
There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ProjectName, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
My project is a WebService project and Configuration Settings is ANYCPU. When I run the project and webservice is hosted on localhost, error page is shown as BadImageFormatException. I also tried to run the project on x86 and x64 settings.
How can I solve this problem? Is there any difference between IIS and IIS Express? When I hit the F5 button and run the project, is localhost running on IIS express?
BadImageFormatException implies you are trying to load the 64 bit assembly into a 32 bit process. In vs 2012 the default is to launch 32 bit IIS express, as pointed out in this User Voice link:
https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3254745-allow-for-iis-express-64-bit-to-run-from-visual-st
You can work around this by hosting in IIS and making sure app pool is 64 bit (which is the default)...or get VS 2013. My suggestion is to always run in IIS to match your production environment.

Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'

I'm using vs2010 and crystal report version 13.0.2000.0 ,system 64bit crystal report runtime 64bit.
my application is running fine on development machine but when i'm deploying on server
getting this error
Could not load file or assembly 'log4net, Version=1.2.10.0,
Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its
dependencies. The system cannot find the file specified.
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 'log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304' or one of its dependencies. The
system cannot find the file specified.
Source of error:
CR:CrystalReportViewer ID="CrystalRportViewrRegistration" runat="server" AutoDataBind="true"
and I have checked GAC assembly I didn't find log4net.dll and even in my system I have search all and tried various things like changing runtime version and uploading lo4net dll from apache but no luck.
To configure IIS to run 32-bit applications you must follow these steps:
Open IIS
Go to current server – > Application Pools
Select the application pool your 32-bit application will run under
Click Advanced setting or Application Pool Default
Set Enable 32-bit Applications to True
If this option is not available to you, follow these next steps:
Go to %windir%\system32\inetsrv\
Execute the appcmd.exe tool:
If you don't see log4net.dll in %systemdrive%\windows\assembly\ on the machine you are attempting to deploy it on, it is likely you haven't successfully installed the redistributable for Crystal Reports for .Net Framework 4.0
Install (or reinstall) the latest service pack from http://scn.sap.com/docs/DOC-7824 (SAP Crystal Reports, developer version for Microsoft Visual Studio Updates & Runtime Downloads)
That runtime distribution should add log4net to the GAC along with a bunch of CrystalDecisions dll's
Ensure version for correct platform (32-bit or 64-bit) is installed. I faced same issue when installed 32-bit run-time on 64-bit machine. Installing correct one, i.e. 64-bit, resolved the issue.
I faced same issue (VS 2015), but my application is running under 32-bit application pool. So even though machine is 64-bit. I installed 32-bit installation and it works.
So in general dll has to be placed in two places:
GAC ( can have 32 and 64 versions of dll's)
your project bin
folder
Thus, you just need add reference to log4net.dll.
(In your case 32-bit with PublicKeyToken=692fbea5521e1304)
You can achive that by
downloading log4net.dll separately and add reference to it
dowloading SAP crystal report SDK (32 bit)
https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads
For this specific error, I installed version 20 of Crystal Report and it solved my problem:
https://www.tektutorialshub.com/crystal-reports/crystal-reports-download-for-visual-studio/#Service-Pack-16
You can also download the file alone using the following link
https://www.nuget.org/api/v2/package/log4net/1.2.10
rename the file to .zip and extract it.
I tried all of that things and it doesn't worked for me.
I Just installed SAPCrystalReport in my computer and it's working now.
To configure IIS to run 32-bit applications you must follow these steps:
Open IIS
Go to current server – > Application Pools
Select the application pool your 32-bit application will run under
Click Advanced setting or Application Pool Default
Set Enable 32-bit Applications to True
This solution worked for me, thanks.
If you are building a windows app try to build as x64 instead of Any CPU. It should work fine.
I was able to resolve this issue using below steps:
Uninstall Crystal reports using 'Add or Remove Programs' on Windows.
Closed all running apps and used this link (https://www.tektutorialshub.com/crystal-reports/how-to-download-and-install-crystal-report-runtime/#hownbspto-download) to download SP 29 DEVELOPER EDITION DOWNLOAD (I was using .net framework 4.7.2, see below Crystal report version recommendation for other versions).
❗ Please note: To integrate “SAP Crystal Reports, developer version for Microsoft Visual Studio” you must run the Install Executable by right clicking and selecting "Run as Administrator". Installing the MSI will not fully integrate Crystal Reports into VS. MSI files by definition are for runtime distribution only. Do not run the MSI's on your Development PC, where VS is installed, not required.
References - https://blogs.sap.com/2020/10/30/upgrading-a-visual-studio-2008-2019-.net-project-with-the-latest-cr-.net-sdk-packages/
https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads
I would say, if you are using 64-bit version of Crystal Reports, just install 32 bit.
That solved my problem.
In my case I migrated crystal report in development computer to last version then migrated the cloud server to same version of crystal report
but after published the site I received this error :
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
the solution I commented the line in web.config
<!--<add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />-->
then publish the site again this solved my issue
Error (While using Visual Studio 2015 in win 10 64 bit machine):
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
Solution:
Open IIS
Go to current server – > Application Pools
Select the application pool your 32-bit application will run under
Click Advanced setting or Application Pool Default
Set Enable 32-bit Applications to True
The above solution is solved my problem.
Thanks.

Word vsto Addin not loading in WIndows XP

I have a small vsto addin for Word that used to work on Word 2010 on Windows XP which was then changed to work on Word 2010 on windows 7. Now, the client wants that plugin to work again on XP and I can't get it to work. I have started the project from scratch in visual studio 2008 to no avail. The difference between the one for Windows 7 and XP was that Windows 7 used Servicemodel and XP used database calls. I have removed the Servicemodel reference and it still doesn't work. I have enabled Fusion logs and the following is what I got. I have done some research where it said not to put any dependencies for the plugin and to install them manually on every machine that this plugin is to be installed on...however, this doesn't seem like an option in our case, as there are many machines this has to be installed on and the users themselves don't have the admin rights to install programs on their machines. Besides, I didn't have to install anything when it worked. Any inputs?
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
LOG: Start binding of native image eMESAHECOWordAddinXP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
LOG: IL assembly loaded from C:\Documents and Settings\Administrator\Local Settings\Application Data\assembly\dl3\E6C2NQ04.WJ1\GC7HN260.7J2\4c4ce18f\00a69b13_9c16ce01\eMESAHECOWordAddinXP.dll.
WRN: No matching native image found.
LOG: Bind to native image assembly did not succeed. Use IL image.
I was able to resolve this issue by setting VSTO_SUPRESSDISPLAYALERTS environment variable to 0. After which Word gave me a popup message stating the issue when it was trying to load the plugin. I installed Office 2007 PIA and everything worked just fine.

Crystal Reports cannot find file

I get the following error on the build of a new application that uses Crystal Reports for VS 2010. On my desktop the reports run, moving to the server has resulted in the following.
Could not load file or assembly 'CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
I developed the reports on a 32 bit os and moved to 64 bit server. The runtime download and install was ver 13_0_4.
Are there references that I am missing or do I need to reinstall the runtime? Do I need to install the Merge Module also?
Any assistance is appreciated.

Visual Studio 2010 - Can't build web site which references 64 bit assembly

How can a web application reference a 64 bit assembly?
I have a solution with a web application and a class library. The class library is set to build on 64bit. The web application by default is Any CPU, but if I build and run I get the following error:
Could not load file or assembly 'ClassLibrary64, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I can't run the project on 32 bits or Any CPU - I'm interacting with SharePoint 2010, and the site must run in 64 bits or the SharePoint API doesn't work...
Any ideas?
IIS is probably running as 32-bit. Why don't you build the class library as AnyCPU?
That will be because your web app is being JIT compiled to 32 bit, so you cannot load a 64 bit assembly into the worker process.
There are very few reasons why you need to compile a web app assembly to a particular bitness. Do you need the class library to be x64, or can you leave it as AnyCPU?
Also, is IIS running on a 64 bit machine with a 64 bit OS? If either is 32 bit only then you won't be able to load the 64 bit assembly anyway.

Resources