AB4D Forum
Problem with ReaderWmf Class in Web Service (WCF) - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Paste2Xaml and Ab2d.ReaderWmf (https://forum.ab4d.com/forumdisplay.php?fid=7)
+--- Thread: Problem with ReaderWmf Class in Web Service (WCF) (/showthread.php?tid=195)



Problem with ReaderWmf Class in Web Service (WCF) - amurciano - 11-02-2011

Hello.

I had a problem with emf/wmf to Silverlight xaml conversion.

I have a Web Service WCF in IIS, and I want do a conversion on the server side.

The following code is a code example :

ReaderWmf wmfReader = new ReaderWmf();
MemoryStream stream = new MemoryStream(_buffer);
wmfReader.Read(stream);

When I use the Read(stream) method of ReaderWmf class :

public Viewbox Read(Stream stream)

I get the following exception (UnauthorizedAccessException):

Access to the path 'c:\windows\system32\inetsrv\be156149-e1c8-4327-a8c5-ef809e05fbad.emf' is denied.

I tried to give the user permissions IIUSR_USERS in this folder, but is not allowed.

As I can do?

Regards.


RE: Problem with ReaderWmf Class in Web Service (WCF) - abenedik - 11-03-2011

The ReaderWmf internally uses some GDI+ interop methods that take only file name as parameter. Therefore the Read method that takes stream as parameter internally creates a temp file in Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) folder.

I would advice you to create the temp metafile by yourself in some known location inside your web application and pass use the Read method that takes file name instead of stream.