John Stagich's Blog

Microsoft .Net Developer

Adding a Local SSRS Report to WPF Application

clock August 20, 2009 07:34 by author johnstagich

On a previous Windows Forms application, I used the ReportViewer control to display the output of local SQL Server Reporting Services (SSRS) reports in my application.  Unfortunately, there is no native WPF Report Viewer control with similar functionality and there will not be one in .Net 4.0 (according to Jamie Rodriguez at Microsoft).  Anyway, the workaround is to use the WinForms ReportViewer control within WPF.  Below is the code that I used.  I had two WPF Windows that I was working with Windows1.xaml and ReportViewer.xaml.  The ReportViewer Window is where I wanted the output of the report to go.  The name of the report file was rptLocations.rdlc.

// Here is the link where I found the code for this routine (Thanks Sayor!):
// http://sayor.blogspot.com/2008/08/report-viewer-in-wpf-application.html

// Add References: Microsoft.ReportVIewer.Common, Microsoft.ReportViewer.WInForms. 

// Add Using statements
using System.Windows.Forms.Integration;
using Microsoft.Reporting.WinForms;

// Get report data
ObservableCollection<BELocation> locationList = new ObservableCollection<BELocation>();
locationList = objLocation.GetAllLocations();

// Create instance of WindowsFormsHost to integrate the report viewer control with the WPF form.
WindowsFormsHost host = new WindowsFormsHost();

// Create instance of Report Viewer Control
Microsoft.Reporting.WinForms.ReportViewer reportViewer = new Microsoft.Reporting.WinForms.ReportViewer();

// Create instance of ReportViewer.xaml Window. This window will contain the output of the report.
Window win = new ReportViewer();

// Specifying local processing mode for the ReportViewer
reportViewer.ProcessingMode = ProcessingMode.Local;

// Specifying the location of the report definition file.  Use the command below, if you set "Copy to Output Directory" property to one of the
// copy options (Copy Always, Copy if newer) for the rptLocations.rdlc file.

       //reportViewer.LocalReport.ReportPath = "rptLocations.rdlc";

// reportViewer1.LocalReport.ReportEmbeddedResource = "<application namespace>.[optional <folder>].<filename.rdlc>

reportViewer.LocalReport.ReportEmbeddedResource = "StagichSoftwareConsulting.WPF_LineOfBusiness.rptLocations.rdlc";

// Create a new ReportDataSource with the name of the DataSource and the object  that is to be used as the DataSource
ReportDataSource ds = new ReportDataSource("BELocation", locationList);

// Add the ReportDataSource to the DataSoure of the ReportViewer
reportViewer.LocalReport.DataSources.Add(ds);

// Causes the current report in the Report Viewer to be processed and rendered.
reportViewer.RefreshReport();

// Sets the child control hosted by the WindowsFormsHost element.
host.Child = reportViewer;

 // Add the WindowsFormsHost element to the Grid in the ReportViewer.xaml
Grid rGrid = (Grid) win.FindName("gridReportViewer");
rGrid.Children.Add(host);

win.ShowDialog();

          



Choose Items Crashes Visual Studio 2008 SP1 Fix

clock August 18, 2009 11:51 by author johnstagich

I wanted to add some controls to my Toolbox in Visual Studio 2008 SP1 IDE.  I right mouse click on the Toolbox and select Choose Items...   It crashed the system.  I did a goolge search and it suggested removing Power Toys.  I checked and my Power Toys were already removed.

I found another suggestion.  Start Visual Studio in safemode and try to add the controls.  To start in Safemode, get to a Visual 2008 command prompt (Programs->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt).  At the command line enter: devenv /safemode.

While in SafeMode, I added the controls.  They did NOT show up in the toolbox; however, when I restarted VS 2008 "normally," the commands apppeared in the Toolbox.

Here is the link where I found the solution: http://forums.asp.net/p/1222006/2570302.aspx#2570302

 



Vista Service Pack 2 Problems / Backup Restores

clock August 17, 2009 09:01 by author johnstagich

After experiencing other difficulties following the aftermath of my Vista Service Pack 2 failed install, I decided to restore to a computer backup I had made about a month before.  (Vista Ultimate has this feature.)  I booted up, tapped the F8 key, and executed the “Repair Your Computer.”  I then selected the restore from computer backup option.  It worked like a charm.  In less than an hour, I was back up and running, plus I picked up about 20 GB in disk space!

 

I then wanted to restore my files from a file backup I had done a few days previously.  Since I had already restored from a computer backup, the file backup became “confused” because the information about my last file backup was wiped out during the computer backup.   Hence, I could not easily restore my latest files from my file backup because the computer could not find the latest backup set on my backup drive.  Fortunately, before performing the computer restore, I manually copied my important files to an external hard drive.  Therefore, instead of continuing to play with the file restore, I manually restored my important files.

 

When I now perform my backups, I will do the Backup Files procedure first, followed by the Backup Computer procedure.  That way if I have to restore from the computer backup, the information about the latest file backup will be there.



Vista Service Pack 2 Install Has Major Problems / Bugs

clock August 5, 2009 10:09 by author johnstagich

I decided to install Vista Service Pace 2.  The install was proceeding smoothly until my machine rebooted and came up with a black screen with scrolling information.  It then appeared to get stuck trying do some work on the registry:  0xc01a001d 17532/46599 (\Registry\Machine\Components\DerivedData...).  The install instructions said not to reboot your computer during the upgrade process.  So, I left the machine alone and came back awhile later, figuring the install should be finished by then.  Wrong!  The machine was dead.  Cycled power and the boot process came up with a screen advising me to repair my system.  I ignore it and try to boot up my PC.  It gets stuck on the same black screen described above.

 I reboot again, this time I take the machine’s advice and I begin the Startup Repair process.  About 90 minutes later, the repair process is still running.  Mind you, there is no diagnostic information to let you know how far along you are in the repair process!  After checking the web and reading about the same problem, I decide to cancel the repair.  I then hit the Cancel button in Startup Repair dialog box.  I get the following message: “The current repair operation cannot be cancelled.  Unbelievable!

I cycle power again, and when rebooting, I press on the F8 key in order to start up Vista in Safe Mode.  I want to boot up in Safe Mode, so I can do a System Restore; however, the machine will not boot up in Safe Mode.  It got stuck on loading drivers.  The last driver loaded was \Windows\system32\drivers\crcdisk.sys.

I cycle power again and press the F8 button.  One of the options the boot screen has is a “Repair Your Computer” option.  I select it and I come to the System Recovery Tools screen.  One of the tools is a System Restore.  Yeah!  I start the restore and select my restore point.  (The Vista Service Pack 2 install was smart enough to create a restore point before proceeding with the install.)  About 60 minutes later the System Restore is stuck on “Finalizing File Restore….”  There is no hard disk drive activity.  Again, absolutely no diagnostic information to let you know how far along you are in the Finalizing File Restore process, or how much longer it will take, or what it is doing.

So let us recap what has transpired:

1)      The Vista Service Pack 2 install failed

2)      The Startup Repair process failed

3)      Trying to boot in Safe Mode failed

4)      The System Restore failed (except for hardware errors, the System Restore should be bullet proof!)

5)      I spent 8 hours trying to fix

Fortunately, after much searching, I came across a fix.  Here is the link: http://social.technet.microsoft.com/forums/en-US/itprovistasp/thread/4491fe25-be44-430e-a384-fb58c5da5ad0/  It is a long thread, but towards the end Arun (go to entry Thursday, May 21, 2009, Mike_jane user name) provides the fix.  It is a “manual” restore done by getting to a command prompt and copying files from the C:\windows\system32\config\Regback directory to the C:\windows\system32\config directory.  

I cycle power, press the F8 button, and select the “Repair Your Computer” option.  I select the “Command Prompt” option and the command window appears.

Here are the commands from the article to enter.  They are copied from the SpecialJ entry, Saturday, July 25 2009.

type in;
cd /d C:\Windows\System32 \Config

(enter)
this should now show

Windows\System32\Config:

then type the following, hitting enter after every line

cd windows\system32\config
ren default default.old
ren sam sam.old
ren security security.old
ren software software.old
ren system system.old
cd regback
copy default c:\windows\system32\config
copy sam c:\windows\system32\config
copy security c:\windows\system32\config
copy software c:\windows\system32\config
copy system c:\windows\system32\config

Note: I did the above steps a little differently.  I renamed the files in the c:\windows\system32\config directory to *.old20090804.  I then copied the *.old entries from the Regback directory into the c:\windows\system32\config directory because their timestamps were just before the Service Pack Install was attempted.  I then removed the .old extension from those files in the c:\windows\system32\config directory.

I then exited the command window and shutdown the computer.  I pressed the power button to restart my PC.  The PC tried to install the Service Pack upgrade again, but failed.  I received the message "Service Pack did not install. Reverting the changes."   The PC automatically rebooted again, and tried to install the Service Pack again, but quickly rebooted, and I was finally back to my login prompt.  The whole process took about 30 minutes.  Many thanks to Arun and SpecialJ!

Enough with Vista Service Pack 2!  I will wait for Windows 7.

If you do try to upgrade to Vista Service Pack 2, I recommend taking the following steps beforehand:

1)      Backup your disk drive

2)      If you have a registry cleaner/repair tool, run it.

3)      Turn off your anti-virus software

 

I WILL look at Apple machines before my next computer purchase!



About the author

I am the owner of Stagich Software Consulting.  Stagich Software Consulting specializes in developing Microsoft .Net/Microsoft SQL software applications.

 

Calendar

<<  December 2024  >>
MoTuWeThFrSaSu
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

View posts in large calendar

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Sign In