Crystal Report in .NET Framework 4.0 - c#

We've a WPF application written in .NET 3.5 using Visual Studio 2010. The solution consists of 8 projects - all compiled in .NET 3.5. The application uses Crystal Report. Target OS is Windows 7.
Recently, the startup project is compiled in .NET 4.0 due to some 3rd party DLL dependency - those DLLs require .NET 4.0. After this change and rebuilding the solution, Crystal Report is throwing exception.
The problem occurs at the constructor of ReportClass.
Exception's message:
The type initializer for
'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an
exception.
InnerException's message:
"Retrieving the COM class factory for component with CLSID
{4DB2E2BB-78E6-4AEA-BEFB-FDAAB610FD1B} failed due to the following
error: 80040154 Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG))."
I haven't worked in Crystal Report before. What could be the cause of this problem?
Please note that this problem doesn't occur when compiled as .NET 3.5. Crystal Report is used in the startup project.

It is likely to be X86/x64 problem.
try to compile your app to target 86 platform.

This issue got me for 2 days and its all over the place with very similar answers, however what it ended up being for me was two-fold. I am adding here in hopes it saves someone at least a day..
A lot of post mention this;
Go to IIS -> application pools -> click right button on your application pools -> go to advance setting -> Enable 32 bit application = True
Please note that in my case I was building and deploying on a 64bit machine so I set the True to False and it did it. Again, simple enough but not something I thought was related so my mind was blank to it after I made the adjustment.
The other point of interest is to make sure that you do have the CRRuntime_xx.x.x.MSI loaded on Deployment server.
Thank you everyone here for the amazing info at the end of the day it got me through.

Go to IIS -> application pools ->click right button on your application pools -> go to advance setting -> Enable 32 bit application = True

When you install CR it should install few files (JS,html etc etc) on C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13. Check if this folder exists on your pc. If not, I think you need to copy the folder from program files to this location.

These answers got us to the right place but not until we did some troubleshooting. It did end up being a 32/64 bit issue on our local dev machines running Visual Studio 2019 and IIS Express.
In our case the issue was that the setting for "Use the 64 bit version of IIS Express for web sites and projects" had been enabled in visual studio settings. We use the 32 bit version of crystal on our dev machines so we had to Uncheck this box for it to work correctly.

Related

0xc00007b Error On Starndard Users

i got problem win i run my application ( Made With VS 2013 - C# )
Only Work On Administration User
if its Standard user Or The PC/Laptop got a Deep Feeze Software Installed
its Show me this Error
The application was unable to start correctly (0xc00007b). click ok to
close the application
i tried to install "all in one runtimes CD"
but its also didnt work
is there any sulotion ?
sorry for my bad english and thank you.
0xc000007b error usually comes from mixing up a 32-bit environment with a 64-bit one. Example, the 32-bit application loads a 64-bit dll causing 0xc000007b error. Try to re-install your application and .NET Framework
Error 0xc00007b occurs because the program that you installed and your system belong to different chipset processors.
E.g. your system is 32-bit and the application which you downloaded is built for 64-bit. So first understand what is your system and application's target platform, then use/run the correct binary files.

Unable to run ASP.NET projects in 64 bit mode on Windows 10 install with VS 2015

We have recently (yesterday) upgraded to Windows 10 and Visual Studio 2015.
Our ASP.NET project will run absolutely fine if we compile to "Any CPU".
We've now tested it on 2 different machines, compiling to x64 produces the error
Exception Details: System.BadImageFormatException: Could not load file or assembly 'OurDLL' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I have been searching for quite a while and most of the troubleshooting I find is for the reverse problem. That is, someone is trying to run a 32 bit ASP app on a 64 bit machine and receiving this error.
I've done everything like deleting all the obj, bin folders etc.
I've also deleted all the temporary .NET files on the computer and also ran aspnet_regiis.exe from the Framework64 directory.
Has anyone experienced this?
Edit: Confirmed with a 3rd person/3rd machine that ASP.NET project do not work in Windows 10 with VS2015 while compiling to x64. It's starting to look like a VS2015 bug.
You have to enable 64x for your projects
Tools -> Options... -> Projects and Solutions -> Web Projects -> Use the 64 bit version of IIS Express for web sites and projects -> Ok
This will enable 64 bit
We had checked this a few times, so evidently it got reverted back to default at some point, and VS still doesn't give a warning or an option to change this option during compiling.
Anyway:
Tools > Options > Projects and Solutions > Web Projects > 'Use the 64 bit
version of IIS Express for websites and projects'
Though we had checked this, I decided to check again.
So in case you are upgrading to VS2015/Windows 10, and using an ASP.NET project, you may want to check this setting a few times especially if you do any .NET updates/Web Tools/VS repairs.

The 'MSDAORA.1' provider is not registered on the local machine

I have an application that connects to a DB, extracts info, creates a excel file, and then drops the file/emails X people the file.
The application was created in Visual Studios using .NET 2.0 Framework (Windows Form App). It was run on a 32 bit server. But it recently was moved to a 64 bit server. It is now returning with the error message " The 'MSDAORA.1' provider is not registered on the local machine."
I believe that MSDAORA is only supported for 32-bit applications and the Application Pool the app runs under in IIS is not enabled for 32-bit applications.
How would I fix this issue, is there something I can change in IIS? Or is it a code change?
Using ORAOLEDB.ORACLE rather than MSDAORA fixed the same issue for me - changing the platform target from 'Any CPU' to 'X86' caused errors within my project in Visual Studio.
See answer here
I figured out the solutions for this. The problem stemmed from running the machine on a 64bit machine. To change that in VS, open up the properties page of the solution and in the build tab change the targeted platform to x86. And that did the trick.
http://lostechies.com/gabrielschenker/2009/10/21/force-net-application-to-run-in-32bit-process-on-64bit-os/
Thanks for your help Yuriy.
I had the same issue, but I used another solution because my application is running in IIS.
In the advanced settings of the application pool I changed the value for Enable 32-Bit Applications to true.
I had he same issue but it wasn't 32/64bit. I used the ODAC xcopy installer and forgot to run it in a cmd.exe as administrator. It didn't give any error so I had a hard time figuring this out. The xcopy part worked but the DLL registration via regsvr32 silently failed.
https://learn.microsoft.com/en-us/sql/ado/guide/appendixes/microsoft-ole-db-provider-for-oracle?view=sql-server-ver15
11/08/2018
This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Instead, use Oracle's OLE DB provider.
so probably using ORAOLEDB.ORACLE is the correct solution, but that seems like more effort than just changing the connection string.

Unable to run c#application (using c++ dll) in some PCs

we have created a c# application which calls a c++ dll(sdbm.dll). It is working properly in most of the PCs except some PCs. The dll is created using VC++ 2008 and application is done in VC# 2005. Following are the errors occured when the dll functions are called from the C# application.
Error occured in one PC is as follows
=====================================
Unable to load sdbm.dll :This application has failed to start because the application configuration is incorrect.Reinstalling the application may fix this problem (Exception from HRESULT :0x800736B1)
Error occured in 2nd PC
=====================================
Error Signature
Appname:app.exe Appver:1.0.0.0 Modname:msvcr90.dll Modver:9.0.30729.4148 Offset:0002fc96
Any help would be appreciated
As the others already stated in their comment it seems to be a problem with the dependencies of your sdbm.dll. The simplest way to find out the root cause you should get a copy of DependencyWalker and throw your sdbm.dll into it. First on a machine where it runs without any problems and afterwards start DependencyWalker on one of the problematic machines to see it's output.
It gives you some informations about what DLLs it couldn't found on the current machine. Thous leading you to the problematic libraries.
Nearly always the problem is a missing Visual C++ Redistributable Package (2005, 2008, 2010) or that your library is compiled and deployed as debug version. In this case it will link to the debug versions of e.g. mfcxx.dll by using the mfcxxd.dll. But these debug versions are only installed with the corresponding SDK (or Visual Studio) and not with the redistribution package. Thus leading to problem on the user machine but not no a developer machine.

I get a "An attempt was made to load a program with an incorrect format" error on a SQL Server replication project

The exact error is as follows
Could not load file or assembly 'Microsoft.SqlServer.Replication,
Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
or one of its dependencies. An attempt was made to load a program with
an incorrect format.
I've recently started working on this project again after a two month move to another project. It worked perfectly before, and I've double checked all the references.
The answer by baldy below is correct, but you may also need to enable 32-bit applications in your AppPool.
Source: http://www.alexjamesbrown.com/uncategorized/could-not-load-file-or-assembly-chilkatdotnet2-or-one-of-its-dependencies-an-attempt-was-made-to-load-a-program-with-an-incorrect-format/
Whilst setting up an application to run on my local machine (running Vista 64bit) I encountered this error:
Could not load file or assembly ChilkatDotNet2 or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
Obviously, the application uses ChilKat components, but it would seem that the version we are using, is only the 32bit version.
To resolve this error, I set my app pool in IIS to allow 32bit applications.
Open up IIS Manager, right click on the app pool, and select Advanced Settings (See below)
Then set "Enable 32-bit Applications" to True.
All done!
I've found the solution. I've recently upgraded my machine to Windows 2008 Server 64-bit. The SqlServer.Replication namespace was written for 32-bit platforms. All I needed to do to get it running again was to set the Target Platform in the Project Build Properties to X86.
Change the value for Platform Target on your web project's property page to Any CPU.
Go to IIS
-> Application Pool -> Advance Settings -> Enable 32-bit Applications
We recently had the issue when trying to run the code from Visual Studio. In that case you need to do
TOOLS > OPTIONS > Projects and Solutions > WEB PROJECTS and check the "Use the 64 bit version of IIS Express for web sites and projects".
For those who get this error in an ASP.NET MVC 3 project, within Visual Studio itself:
In an ASP.NET MVC 3 app I'm working on, I tried adding a reference to Microsoft.SqlServer.BatchParser to a project to resolve a problem where it was missing on a deployment server. (Our app uses SMO; the correct fix was to install SQL Server Native Client and a couple other things on the deployment server.)
Even after I removed the reference to BatchParser, I kept getting the "An attempt was made..." error, referencing the BatchParser DLL, on every ASP.NET MVC 3 page I opened, and that error was followed by dozens of page parsing errors.
If this happens to you, do a file search and see if the DLL is still in one of your project's \bin folders. Even if you do a rebuild, Visual Studio doesn't necessarily clear out everything in all your \bin folders. When I deleted the DLL from the bin and built again, the error went away.
I had this in an MVC5 app in Windows 10 against IIS Express. My solution was the following:
Tools =>
Options =>
Projects and Solutions =>
Web Projects =>
Use the 64 bit version of IIS Express for web sites and projects
change it to 32-bit (true) it works
if you get this Length cannot be less than zero. Parameter name: length issue in iis server configuation do the simple thing change the connection string in web.config file like your sql server name and server name and restart iis then try to load the page it works
If Publishing in Visual Studio 2012 when erroring try unchecking the "Procompile during publishing" option in the Publish wizard.
in windows form application I do this,
Right-click on Project->Properties->Build->Check Prefer 32-bit checkbox.
Thanks all
Delete the temp test directory located here
C:\Users(User)\AppData\Local\Temp\VisualStudioTestExplorerExtensions\
Set all projects to x64 in Visual Studio
Set the default processor architecture to x64(Test/TestSettings/Default Processor Architecture).
Make sure to clean build the solution file.Hope this helps!
Changing the Target Framework in project properties from .NET Framework 4.7.1 to 4.6.2 worked for me.

Categories