1

I have added the following reference to my winforms C# project:

CrystalDecisions.CrystalReports.Engine
CrystalDecisions.ReportSource
CrystalDecisions.Shared

but no matter what I do i can't use the .dll's in any of my .cs pages. I get the following warning when I add the CrystalRecisions references:

Warning The referenced assembly "CrystalDecisions.CrystalReports.Engine,      Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.

From the error above I can see that it says that it has a dependency on system.web but what do I do from here? What do i need to download in order to run Crystal Reports from my Winforms C# application?

MDL
  • 261
  • 2
  • 12
  • 23

2 Answers2

6

Read the warning! It tells you exactly what's wrong: Your application is targeted to the .NET Framework 4 Client Profile, which does not include System.Web.

Open the project properties, make sure the Application tab is active, and change the value for Target Framework to .NET Framework 4.

phoog
  • 42,068
  • 6
  • 79
  • 117
1

System.Web is one of the core .NET packages. You need to right-click on your references folder in your project, left click "Add Reference..." and locate System.Web from the list on the .NET tab (which should be the default tab.)

Hopefully this will resolve your problem.

Matt T
  • 511
  • 2
  • 8
  • I don't understand why Crystal Reports would need system.web though since this is a Winforms project. – MDL Feb 22 '12 at 18:56
  • I don't have an answer for that, but it does appear to be the source of your problem. – Matt T Feb 22 '12 at 18:57
  • maybe if I reinstall all crystal reports things this will stop happening. – MDL Feb 22 '12 at 19:04
  • 2
    @MDL: Crystal Reports is such a mismashed beast whose ownership has gone through *several* companies. Understanding *why* it does anything isn't feasible. Also note that CR won't work under the .net Client Profile.. probably for the same reason. – NotMe Feb 22 '12 at 19:09
  • 1
    @MattT `System.Web` is one of the core .NET packages that is *omitted from the Client Profile*, and that's the OP's problem. – phoog Feb 22 '12 at 19:13
  • @ChrisLively and in fact that is the cause of the OP's problem. – phoog Feb 22 '12 at 19:14
  • The "Client Profile" is simply a template. Whether he changes the profile or adds the necessary references, the end result is the same - and my way will likely result in fewer "extra" references. – Matt T Feb 22 '12 at 19:19
  • @MattT that's not right. See http://stackoverflow.com/questions/3741705/cannot-add-system-web-dll-reference. Besides, if adding the reference would fix the problem, the message would say "add the reference"; rather, it says "consider changing the target framework". – phoog Feb 22 '12 at 20:27
  • @MattT see also the documentation for the client profile, which says "If you are targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4.": http://msdn.microsoft.com/en-us/library/cc656912.aspx – phoog Feb 22 '12 at 20:30