Display .RDLC report embedded in a DLL file - reporting-services

I have a report that is used by a windows service and a form application. So, I want to put embed the report in a DLL file that can be used by both.
The problem is that if I try to set the ReportEmbeddedResource property of a ReportViewer control in my windows form app, it will search the windows form app for the resource, not the dll file.
e.g.: Code from the windows form app:
rv.LocalReport.ReportEmbeddedResource = "MyReportInMyDLLFile.rdlc"
How can I make the above command look for the embedded resource in my DLL file?

Something like this should do it:
Assembly assembly = Assembly.LoadFrom("Reports.dll");
Stream stream = assembly.GetManifestResourceStream("Reports.MyReport.rdlc");
reportViewer.LocalReport.LoadReportDefinition(stream);

Just use the full namespace of the assembly, then folder names and then the name of the file:
rv.LocalReport.ReportEmbeddedResource =
"My.Assembly.Namespace.Folder1.Folder2.MyReport.rdlc";
Then make sure the report file is set as an embedded resource using the properties pane.

Probably the best thing to do would be to get a stream to the RDLC resource from the other assembly, then pass that to the "LoadReportDefinition" method of the Report Viewer control.
Details of how to get a stream from an embedded resource in a different assembly can be found here : Retrieving Resources with the ResourceManager Class
Additionally, you will need to refer to the embedded resource using it's full namespace path.
E.g. if you have an application with a default namespace of TheApp, and you keep a report called "MyReport.rdlc" in a folder called "Reports", the report reference call would be:-
rv.LocalReport.ReportEmbeddedResource = "TheApp.Reports.MyReport.rdlc";

Related

How to build rptproj using C#

I want to build all my reports project and copy .rdl files to other location.
I am using MSBuild.Engine for same.
Engine engine = new Engine();
// Point to the path that contains the .NET Framework 2.0 CLR and tools
engine.BinPath = #"c:\windows\microsoft.net\framework\v2.0.50727";
// Instantiate a new FileLogger to generate build log
FileLogger logger = new FileLogger();
// Set the logfile parameter to indicate the log destination
logger.Parameters = #"logfile=C:\temp\build.log";
// Register the logger with the engine
engine.RegisterLogger(logger);
// Build a project file
bool success = engine.BuildProjectFile(#"xyz.rptproj");
//Unregister all loggers to close the log file
engine.UnregisterAllLoggers();
if (success)
Console.WriteLine("Build succeeded.");
else
Console.WriteLine(#"Build failed. View C:\temp\build.log for details");
Also I am getting error that cannot build this project.
Error log says below:
error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element.
Can someone help or suggest me?
Thanks
This may not be the best answer, but you could create a blank class library project in visual studio, for build and install purposes. Add each RDL file to the project, they can exist on another project so the link (file path in the .csproj) to the file can point to where they actually live on another project in source control. Mark each file as "content" and to "copy always". After that is saved and part of a solution, you can call MSbuild to build that project and use the content output of the build, or this can also be used in an installer to use the content output from the project and specify where you want the install folder to live.

MS Access: pass attached file into adobe PDF control

I have a form / report that I need to get images to display on, but they are all received in PDF format which the attachment control can't display.
To get around this I was planning on using the Adobe PDF activex control, but I can't just pass it a file path since this database will be used for reporting by people that do not have access to the network shares these PDF files will be on.
Ideally I would like to store the file in the database and then pass this stored version into the control. I am having trouble finding documentation on what I can do with the adobe pdf control.
I am imaginging something like:
AcroPDF1.LoadFile (Me.attachment)
Is this possible?
What you need a database-linked PDF viewer.
Delphi: http://www.gnostice.com/nl_article.asp?id=274&t=Data_aware_VCL_component_to_display_DOCX_PDF_BMP_PNG_JPEG_from_a_database
.NET: http://www.gnostice.com/nl_article.asp?id=279&t=How_to_save_and_retrieve_PDF_documents_to_and_from_a_database_using_C
You will have to modify the data source with a network DB.

Opening html file from IsolatedStorage in a WebBrowser componenet in Windows Phone

I have stored an HTML file in IsolatedStorage as test.html.
In UI I have a WebBrowser component called browser. I'm using the following code to show the webpage in the browser:
browser.Navigate(new Uri("isostore:/test.html", UriKind.Absolute));
However it's giving me the prompt to search for an app in store, as if I'm trying to use LaunchUriAsync or LaunchFileAsync API.
I guess the problem is with the Uri format. What should be the correct Uri format in this case?
I have solved it, by removing 'isostore:/' prefix from the Uri string. I know that without any prefix the file path would refer to the application folder, not the isolated storage. It seems they've made an exception for the WebBrowser component.
This is what works now:
browser.Navigate(new Uri("test.html", UriKind.Relative));
C:/Data/Users/DefApps/AppData/{43F7CB8F-D4CF-425D-96BD-CD96D3FF44DC}/Local/test.html
The path above is an alternative and absolute path to the isolated storage. This string, {43F7CB8F-D4CF-425D-96BD-CD96D3FF44DC}, is unique to the app but can be set/found from within the properties folder of your visual studio project. You can also obtain it by using the following lines in the C# code:
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
String mystring = localFolder.Path;

Dashboard widget: how to bind a list to a non-web XML datasource

I have an XML file located on my desktop that I would like to bind to a dashboard widget list (tableview). Although I am able to bind this file if it's within the widget's bundle folder, I am unable to bind the XML file to the list externally. A modal dialog warning shows: "try entering a path relative to your application"--yet this also does not seem to work. And yes, I made sure to check the "Allow external file access" within the Widget Attributes panel.
I think I have found a solution: instead of using the conventional unix file path for the datasource reference, e.g. '/Desktop/myXMLFile.xml', I find that an XML file also has a URL path: 'file:///~/Desktop/myXMLFile.xml'. Coming from the world of Cocoa programming, I was ignorant of XML files and widget behavior as a web 2.0 kind-of-thing.

Loading HTML from a .res file

Using VS2005/2008 as a resource editor, one of the options in the Add Resource dialog is HTML: it appears to allow me to embed HTML file(s) into a resource (res) file. Does anyone know how to grab the HTML (as a string) from VB6 code? The LoadResData appears to be close to what I'm looking for but the problem is there isn't a HTML format defined in the table of formats (in that documentation link).
In Win32 C headers a resource format constant is defined called RT_HTML, it has the value 23. It should be possible to load the HTML resource type. Additionally you can verify the resource type number by looking at the built exe file with Resource Hacker. It lists the resource format types and resource IDs embedded in the file.
here is a good tutorial in c++ http://www.rohitab.com/discuss/index.php?showtopic=15281
you can probably adapt the code(usually function names are the same for win32 routines search on msdn.microsoft.com for documentation) or search the website for a VB example