views:

49

answers:

6

I am using ItextSharp and I am getting a new font for it by doing this

string  fontPath = Path.GetFullPath("C:\\BMSApplicationFiles\\Fonts\\FREE3OF9.TTF");
BaseFont barCodeBase = BaseFont.CreateFont(fontPath, BaseFont.CP1252, BaseFont.EMBEDDED);

That file is in that directory on both my dev machine and the server. When i run this on my dev machine it works fine, when published to my server I get an error saying FREE3OF9.TTF is not found as a file or a resource. I have double and triple checked that the file is in fact there on my server. My application has full trust on IIS. and IIS user has full access to this folder. And still I get this error. Very frustrating. Any ideas??

This code is Not inside the Web Application but inside a DLL class library that the web application is referencing. Do I need to add any more special permissions or something?

A: 

Most probably you have a security issue.

If you run IIS7 then check that IIS_IUSRS group has an access to the file (open file properties in explorer select Security tab etc).

If you run IIS6 then check that IUSR_MachineName account has an access to the file.

konstantin.zaikin
as mentioned in my original post, I have checked and double checked all of this. Still the same error
twal
A: 

The Stack trace does not add much more info

System.IO.IOException: C:\BMSApplicationFiles\Fonts\FREE3OF9.TTF not found as file or resource. at Bullfrog.BMS.Services.InventoryItemService.GetShelfLabel(String[] invoices, String fontPath) in C:\Users\twaldron.BULLFROGSPAS\Documents\Projects\Bullfrog.BMS\Bullfrog.BMS.Services\InventoryItemService.cs:line 411 at Bullfrog.BMS.Web.Areas.PurchasingReceiving.Controllers.ItemMasterController.PrintShelfLabelSingle(String id) in C:\Users\twaldron.BULLFROGSPAS\Documents\Projects\Bullfrog.BMS\Bullfrog.BMS.Web\Areas\PurchasingReceiving\Controllers\ItemMasterController.cs:line 490

twal
A: 

Your next step should be to confirm that what you think is happening is happening. If you are allowed to, download and install Process Monitor which will allow you to log activity including which files are being attempted to be accessed and by which user account. Apply filters when monitoring of course, or else you'll end up seeing all the activity on the server...

If that only confirms that the correct file is being attempted to be read by expected user then maybe there's something up with the font. Try replacing the font file temporarily with another standard one (e.g. arial or something) and see what happens. (this is unlikely to help as it works on your dev machine, but might be worth a go)

FinnNk
I have installed process monitor. when i go through the action that shoud go get this font i see all the other files such as the .js files being accessed in process monitor, but there is no where that says anything about the font file. I did is search for the stem and if finds nothing. I replaced it with an other common font and still get a similar error for that font as well.
twal
There are a bunch of Fast IO Disallowed and path not found results that correspond to the path to the controller that would get call the method that would access this font, but nothing pertaining to this file.
twal
A: 

Any one have any other thoughts on this? I am at a complete dead end until i get this working.

twal
A: 

Now I have taken the file added it to my application and I am trying to create the PDF right in my controller, not going out to an class library. so I am trying to access this file now using this right in my controller

   string fontPath = Server.MapPath("../../../Content/Fonts/FREE3OF9.TTF");

so my file gets deployed with the application now. Again it works on my dev machine but I get the exact same error on my server. It is in the same project now. How can it say it can't find the fie when it is there and it is in the same poject. Just like all the images, css, and javascripts files that are all working fine. I really do no understand why this is not working on my server.

twal
A: 

I had a similar error when I tried to get it working with IIS. Within IIS, I had to add he file directory as a virtual drive. That worked for me when I had a similar situation set up. Hopefully it works for you, best of luck

Link