fix locator to prevent fileload exception in reflection only context for referenced dlls of plugins.
added probing path to app.config to include dlls in the plugins dir. updated pdf exporter code to the working code. still doesnt work on stream code though.
This commit is contained in:
parent
568f399a3f
commit
cf2f5a72ae
@ -44,6 +44,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Threading;
|
||||
using Interfaces;
|
||||
using Syncfusion.HtmlConverter;
|
||||
using Syncfusion.Pdf;
|
||||
using Syncfusion.Pdf.Graphics;
|
||||
|
||||
namespace PDFExporter
|
||||
{
|
||||
@ -28,11 +29,44 @@ namespace PDFExporter
|
||||
|
||||
void DoExport(string fileContent, string baseUrl)
|
||||
{
|
||||
var pdfExporter = new HtmlToPdfConverter();
|
||||
//var pdfExporter = new HtmlToPdfConverter();
|
||||
//var settings2 = new IEConverterSettings();
|
||||
//settings2.AdditionalDelay = 2000;
|
||||
//pdfExporter.ConverterSettings = settings2;
|
||||
//PdfDocument doc = pdfExporter.Convert(fileContent, baseUrl);
|
||||
|
||||
|
||||
var conv = new HtmlToPdfConverter();
|
||||
|
||||
PdfDocument document = new PdfDocument();
|
||||
//Set page margins and dimensions.
|
||||
|
||||
PdfUnitConvertor convertor = new PdfUnitConvertor();
|
||||
|
||||
float width = convertor.ConvertToPixels(document.PageSettings.Width, PdfGraphicsUnit.Point);
|
||||
float height = convertor.ConvertToPixels(document.PageSettings.Height, PdfGraphicsUnit.Point);
|
||||
|
||||
var settings = new IEConverterSettings();
|
||||
settings.AdditionalDelay = 2000;
|
||||
pdfExporter.ConverterSettings = settings;
|
||||
PdfDocument doc = pdfExporter.Convert(fileContent, baseUrl);
|
||||
|
||||
settings.EnableHyperLink = true;
|
||||
settings.EnableJavaScript = true;
|
||||
settings.SplitImages = false;
|
||||
settings.SplitTextLines = false;
|
||||
|
||||
settings.Margin.All = 20.0f;
|
||||
|
||||
settings.PdfPageSize = PdfPageSize.A4;
|
||||
|
||||
conv.ConverterSettings = settings;
|
||||
|
||||
//Convert the URL/HTML string by providing the required width and height.
|
||||
var doc = conv.Convert(@"http://www.bbc.co.uk", width, height, AspectRatio.KeepWidth);
|
||||
doc.PageSettings.Size = PdfPageSize.A4;
|
||||
doc.PageSettings.SetMargins((float)20.0f);
|
||||
|
||||
doc.Save("c:\\zzz\\test3.pdf");
|
||||
//doc.Close(true);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
doc.Save(ms);
|
||||
doc.Close(true);
|
||||
|
||||
@ -58,7 +58,7 @@ namespace RaceLapTimer
|
||||
// id.Close();
|
||||
// id.Dispose();
|
||||
// fs.Flush(true);
|
||||
// fs.Close();
|
||||
// fs.Close(); //this still isnt saving the file.. :(
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@ -40,9 +41,18 @@ namespace RaceLapTimer.Extensions
|
||||
if (!IsAssembly(ext)) continue;
|
||||
|
||||
var assembly = Assembly.ReflectionOnlyLoadFrom(file);
|
||||
var pluginTypes = (from t in assembly.GetExportedTypes()
|
||||
where t.GetInterfaces().Any(x => x.Name == typeof(T).Name)
|
||||
select t).ToList();
|
||||
var pluginTypes = new List<Type>();
|
||||
try
|
||||
{
|
||||
pluginTypes.AddRange((from t in assembly.GetExportedTypes()
|
||||
where t.GetInterfaces().Any(x => x.Name == typeof(T).Name)
|
||||
select t).ToList());
|
||||
}
|
||||
catch (FileLoadException flex)
|
||||
{
|
||||
_logger.Error(flex);
|
||||
}
|
||||
|
||||
if (pluginTypes.Any())
|
||||
{
|
||||
discoveryList.Add(new DiscoveredPlugin
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
<assemblyIdentity name="Ninject.Extensions.ChildKernel" publicKeyToken="c7192dc5380945e7" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" />
|
||||
</dependentAssembly>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<probing privatePath="plugins"/>
|
||||
</assemblyBinding>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@ -96,10 +96,10 @@ copy /B /Y "$(TargetDir)NLogConfig.xml" "$(TargetDir)Configs\NLogConfig.xml"
|
||||
copy /B /Y "$(SolutionDir)RaceLapTimer\$(OutDir)Ninject.Extensions.Xml.dll" "$(TargetDir)Ninject.Extensions.Xml.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)PDFExporter.dll" "$(TargetDir)Plugins\PDFExporter.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir).dll" "$(TargetDir)Plugins\PDFExporter.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.HtmlConverter.Base.dll" "$(TargetDir)Syncfusion.HtmlConverter.Base.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Pdf.Base.dll" "$(TargetDir)Syncfusion.Pdf.Base.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Compression.Base.dll" "$(TargetDir)Syncfusion.Compression.Base.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Microsoft.mshtml.dll" "$(TargetDir)Microsoft.mshtml.dll"</PostBuildEvent>
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.HtmlConverter.Base.dll" "$(TargetDir)Plugins\Syncfusion.HtmlConverter.Base.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Pdf.Base.dll" "$(TargetDir)Plugins\Syncfusion.Pdf.Base.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Compression.Base.dll" "$(TargetDir)Plugins\Syncfusion.Compression.Base.dll"
|
||||
copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Microsoft.mshtml.dll" "$(TargetDir)Plugins\Microsoft.mshtml.dll"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user