PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:09 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Nov 29, 2018 3:39 pm 
Offline

Joined: Thu Nov 29, 2018 3:02 pm
Posts: 2
Hi all

Apologies for my first post being a support request - I hope it will be easy to answer. I wrote a C# Windows Service, fetched the PDFsharp-MigraDoc-GDI package using NuGet, then added some logic based on one of the MigraDoc code samples. My program worked on my development machine, but when deployed to a live server, it fails System.UnauthorizedAcessException. I added some diags, writing to Event Viewer logs at various points throughout the code, and this is the failing statement:-

Code:
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");

The user account that the Windows Service runs under has read/write permissions on the target folder where I am trying to save documents.
I noted that the MigraDoc and PDFsharp dlls are not saved in the GAC.

Can anyone advise a workaround please? I hope it is something simple.

Many thanks

This is the error stack.

Code:
Application: MyService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.UnauthorizedAccessException
   at System.IO.__Error.WinIOError(Int32, System.String)
   at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
   at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean)
   at System.IO.StreamWriter.CreateFile(System.String, Boolean, Boolean)
   at System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean)
   at System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding)
   at MigraDoc.DocumentObjectModel.IO.DdlWriter..ctor(System.String)
   at MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(MigraDoc.DocumentObjectModel.DocumentObject, System.String, Int32, Int32)
   at MyService.exe.Create_Response_Files()
   at MyService.exe.Process_Response()
   at MyService.exe.Process_Request(System.String)
   at MyService.exe.MyService.ReadCallback(System.IAsyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr)
   at System.Net.ContextAwareResult.CompleteCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Net.ContextAwareResult.Complete(IntPtr)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 29, 2018 4:12 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Hi!
RichardF wrote:
Can anyone advise a workaround please? I hope it is something simple.
It is something simple.
The file "MigraDoc.mdddl" is created for debugging purposes only. Remove the line and you're done.
Specify a folder with write access if you ever need that file for debugging.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 29, 2018 4:20 pm 
Offline

Joined: Thu Nov 29, 2018 3:02 pm
Posts: 2
Hi Thomas - that's great, all fixed. I am now at the next solution start-point :)

Many thanks

Richard

TH-Soft wrote:
Hi!
RichardF wrote:
Can anyone advise a workaround please? I hope it is something simple.
It is something simple.
The file "MigraDoc.mdddl" is created for debugging purposes only. Remove the line and you're done.
Specify a folder with write access if you ever need that file for debugging.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 154 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group