Problem with ReaderWmf Class in Web Service (WCF)

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);

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?

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.
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)