At work I have encountered a problem with EvoPdf for DotNet client where it won't actually convert the html because of the following exception:
An error occured. Initialization failed: Insufficient data
The stack trace shows the following:
at am.aa()
at EvoPdf.HtmlToPdfClient.HtmlToPdfConverter.ConvertHtml(String html, String baseUrl)
at evoPdfTest.Program.Main(String[] args) in D:\git\evoPdfTest\evoPdfTest\Program.cs:line 32
This of course makes no sense, because in order to verify it wasn't anything I did, I decided to make a small console app as follows (also this same error occurs in their demo code as well.
var pdfConverter = new HtmlToPdfConverter(myIpString, myPort);
var paragraphHtml = $$"<!DOCTYPE html><html> <body> The content of the body element is displayed in your browser.</body></html> "";
pdfConverter.LicenseKey = myKey;
// Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed
// Set this property to 0 if you don't need to wait for such asynchcronous operations to finish
pdfConverter.ConversionDelay = 2;
// set PDF page size
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
// set PDF page orientation
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Portrait;
var pdfBytes = pdfConverter.ConvertHtml(paragraphHtml, null);
Where am I going wrong, and is this just a case of a superemly poorly written error message?
For anyone getting this error in the future:
An error occured. Initialization failed: Insufficient data
This occurs due to a mismatch in versions. In our case, we had an Azure Function running version 8.0.0 of the EvoPDF NuGet library and an Azure Cloud Application endpoint running version 7.5.0. Ensure that all services are running the same version.
Related
With the reference from below link
https://github.com/nkranitz/transloadit-csharp-sdk
Am using transloadit for video converting and saving it in s3 in C#. I am able to upload the video and image and am able to get the response with empty results. My response had "ok": "ASSEMBLY_EXECUTING", message and the results tag is empty. So am not getting the final response once the assembly is executed like ASSEMBLY_COMPLETED. So, i see that there is some property assembly.setblocking = true.. but in C# that property is not available. So how can i get the final response or how can i use blocking property in c#.net
Please help me out in solving this issue.
Thanks in advance.
Below is the code snippet
ITransloadit transloadit = new Transloadit.Transloadit("APIKEY", "Secret");
//Create assembly builder to build up the assembly
IAssemblyBuilder assembly = new AssemblyBuilder();
//Add a file to be uploaded (with autogenerated key)
assembly.AddFile(#"filepath");
//Define the step, you can define more in the same assembly
IStep step = new Step();
step.SetOption("robot", "/image/resize");
step.SetOption("width", 75);
step.SetOption("height", 75);
step.SetOption("resize_strategy", "pad");
step.SetOption("background", "#000000");
//Add the step to the assembly
assembly.AddStep("thumb", step);
//Set notification URL
assembly.SetNotifyURL("url");
//Set the expiration date time of the request for the assembly
//Assembly will be expired in 120 minutes from now
assembly.SetAuthExpires(DateTime.Now.AddMinutes(120));
//Invoke assembly, and wait for the result
TransloaditResponse response = transloadit.InvokeAssembly(assembly);
if (response.Success)
{
// LoggerFactory.GetLogger().LogInfo(Type.GetType("TestConsole.Program"), "Assembly {0} result", response.Data);
}
In that first response, you should see an assembly_url. You can/should poll that URL every X seconds to get the updates. When the assembly reaches ASSEMBLY_CANCELED ASSEMBLY_COMPLETED REQUEST_ABORTED, or the error is set, it's done. I'm not sure if the boilerplate for this polling is implemented in the SDK, you'd have to check.
Blocking assemblies are not recommended as they require to keep the connection open, which is more brittle.
Update: I downloaded Ramone project, added it to my project and then ran the application again with debugger. The error is shown below:
public MediaTypeWriterRegistration GetWriter(Type t, MediaType mediaType)
{
...
CodecEntry entry = SelectWriters(t, mediaType).FirstOrDefault(); => this line throws error
...
}
Error occurs in CodecManager.cs. I am trying to figure out why it does not recognize json-patch media type. Could it be because writer is not being registered correctly? I am looking into it. If you figure out the problem, please let me know. Since you are the author of the library, it will be easier for you to figure out the issue. I will have to go through all the code files and methods to find the issue. Thanks!
I was excited to know that Ramone library supports json-patch operations but when I tried it, I got following error:
415- Unsupported Media Type
This is the same error that I get when I use RestSharp. I thought may be RestSharp does not support json-patch and errors out so I decided to try Ramone lib but I still get same error. Endpoint has no issues because when I try same command using Postman, it works but when I try it programmatically in C#, it throws unsupported media type error. Here is my code:
var authenticator = new TokenProvider("gfdsfdsfdsafdsafsadfsdrj5o97jgvegh", "sadfdsafdsafdsfgfdhgfhehrerhgJ");
JsonPatchDocument patch = new JsonPatchDocument<MetaData>();
patch.Add("/Resident2", "Boyle");
//patch.Replace("/Resident", "Boyle");
RSession = RamoneConfiguration.NewSession(new Uri("https://api.box.com"));
RSession.DefaultRequestMediaType = MediaType.ApplicationJson;
RSession.DefaultResponseMediaType = MediaType.ApplicationJson;
Ramone.Request ramonerequest = RSession.Bind("/2.0/files/323433290812/metadata");
ramonerequest.Header("Authorization", "Bearer " + authenticator.GetAccessToken(code).AccessToken);
//var ramoneresponse = ramonerequest.Patch(patch); //results in error: 405 - Method Not Allowed
var ramoneresponse = ramonerequest.Put(patch); //results in error: 415 - Unsupported Media Type
var responsebody = ramoneresponse.Body
Endpoint information is available here: http://developers.box.com/metadata-api
I used json-patch section in the following article as a reference:
http://elfisk.dk/Ramone/Documentation/Ramone.pdf
By the way I tried Patch() method (as shown in above ref. article) but that resulted in "Method not allowed" so I used Put() method which seems to work but then errors out because of json-patch operation.
Any help, guidance, tips in resolving this problem will be highly appreciated. Thanks much in advance.
-Sham
The Box documentation says you should use PUT (which is quite a bit funny). The server even tells you that it doesn't support the HTTP PATCH method (405 Method Not Allowed) - so PUT it must be.
Now, you tell Ramone to use JSON all the time (RSession.DefaultRequestMediaType = MediaType.ApplicationJson), so you end up PUT'ing a JSON document to Box - where you should be PUT'ing a JSON-Patch document.
Drop the "RSession.DefaultRequestMediaType = MediaType.ApplicationJson" statement and send the patch document as JSON-Patch with the use of: ramonerequest.ContentType("application/json-patch+json").Put(...).
I am using DotNetCharting version 4.2. I am trying to create a chart, save it to disk and return the path as a string. Here is a simplified version of my code thus far.
Chart aChart = new Chart();
aChart aChart.Title = "Some Title";
aChart aChart.ChartArea.Background = new Background(Color.White);
aChart.TempDirectory = "C:\\temp\\"
aChart.Width = chartWidth;
aChart.Height = chartHeight;
imageName = aChart.FileManager.SaveImage();
I got this from this dotnetCharting support page. It is very straightforward code.
Here is the problem: The code above actually DOES create an image in the appropriate directory. This is NOT a directory permissions issue. When I add my actual data to the aChart, it actually DOES add it and an image is created. However, the SaveImage() method always throws an exception of "Failed to map the path '/'." The SaveImage() method is supposed to return a String, however, it always returns "" and the exception is thrown.
More Info: I am doing this in a WCF Service. Is it possible that since it's in a service the dotNetCharting DLL is having trouble with some internal MapPath?
I just upgraded the DotNetCharting to the latest version (7.0) and now it works fine. I believe that it was an issue with the old version of the DLL. I'll leave this here in case anyone else has this issue.
Getting this exception The file size exceeds the limit allowed and cannot be saved when writing to event viewer using EventLog
Code used:
string cs = "LoggingService";
EventLog elog = new EventLog();
if (!EventLog.SourceExists(cs))
{
EventLog.CreateEventSource(cs, cs);
}
elog.Source = cs;
elog.EnableRaisingEvents = true;
elog.WriteEntry(message);
Stack trace:
System.ComponentModel.Win32Exception (0x80004005): The file size exceeds the limit allowed and cannot be saved
at System.Diagnostics.EventLogInternal.get_OldestEntryNumber()
at System.Diagnostics.EventLogInternal.StartRaisingEvents(String currentMachineName, String currentLogName)
at System.Diagnostics.EventLogInternal.set_EnableRaisingEvents(Boolean value)
Things tried:
http://support.microsoft.com/kb/328380#top
When I put this statement elog.Clear() before elog.EnableRaisingEvents = true;
I am getting different exception
System.ComponentModel.Win32Exception (0x80004005): Access is denied
at System.Diagnostics.EventLogInternal.Clear()
The above code is executed by a web service which runs under LocalSystem which has full permission on the computer.
OS: windows server 2008R2 and .NET 4.0
There is a method EventLog.ModifyOverflowPolicy that modifies log policy.
I believe EventLog.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded,0) could be helpful.
Event Viewer - Properties - Maximum log size was 1028. I bumped it and it started working fine.
But the same code was working from another window service before I made the above the change.
which make me think what could have happened
The message I was trying to log was just a line (less then 255 characters)
I'm looking for help from anyone who's worked with the verbot sdk.
I'm making a program that I want to use the LearnedKnowledge.vkb, Teacher.vkb, and any standard bot (julia, for example). Those who've used this before will know that with the rules in Teacher, you can essentially write responses to things that the bot doesn't understand, and train it on the fly.
I'm planning on using speech recognition and text-to-speech, but my problem right now is that after I load the knowledgebases, I can't seem to get any response from the bot.
Here's what I have: The Verbot5Library.dll, from verbots.sourceforge.net (I got the editor and player too, to make sure the files were working). In my program, I set up the variables as such:
Verbot5Engine verbot = new Verbot5Engine();
KnowledgeBase kb = new KnowledgeBase();
KnowledgeBaseItem kbi = new KnowledgeBaseItem();
State state = new State();
XMLToolbox xmlToolboxKB = new XMLToolbox(typeof(KnowledgeBase));
Then I initialize the verbot engine and load the kbs:
// using the xmlToolboxKB method I saw in this forum: http://www.verbots.com/forums/viewtopic.php?t=2984
kbi.Fullpath = #"C:\\[full path to kb...]\\";
kbi.Filename = "LearnedKnowledge.vkb";
kb = (KnowledgeBase)xmlToolboxKB.LoadXML(kbi.Fullpath + kbi.Filename);
verbot.AddKnowledgeBase(kb, kbi);
kbi.Filename = "julia.vkb";
kb = (KnowledgeBase)xmlToolboxKB.LoadXML(kbi.Fullpath + kbi.Filename);
verbot.AddKnowledgeBase(kb, kbi);
//trying to use LoadKnowledgeBase and LoadCompiledKnowledgeBase methods: verbot.LoadKnowledgeBase("C:\\[full path to kb...]\\LearnedKnowledge.vkb");
//verbot.LoadCompiledKnowledgeBase("C:\\[full path...]\\julia.ckb");
//verbot.LoadCompiledKnowledgeBase("C:\\[full path...]\\Teacher.ckb");
// set up state
state.CurrentKBs.Add("C:\\[full path...]\\LearnedKnowledge.vkb");
state.CurrentKBs.Add("C:\\[full path...]\\Teacher.vkb");
state.CurrentKBs.Add("C:\\[full path...]\\julia.ckb");
Finally, I attempt to get a response from the verbot engine:
Reply reply = verbot.GetReply("hello", state);
if (reply != null)
Console.WriteLine(reply.AgentText);
else
Console.WriteLine("No reply found.");
I know julia has a response for "hello", as I've tested it with the editor. But all it ever returns is "No reply found". This code has been taken from the example console program in the SDK download (as very little documentation is available). That's why I need some pointers from someone who's familiar with the SDK.
Am I not loading the KBs correctly? Do they all need to be compiled (.ckb) instead of the XML files (.vkb)? I've used the verbot.OnKnowledgeBaseLoadError event handler and I get no errors. I even removed the resource file Default.vsn needed to load the Teacher, and it throws an error when trying to load it so I'm pretty sure it's all loading correctly. So why do I always get "No reply found"?
resolved: see http://www.verbots.com/forums/viewtopic.php?p=13021#13021