0

I working on a silverlight application that works OOB. When i debug the application in VS2010 it works like charm, and even when i install it on my PC. The application is using Excel COM Automation to automatically create, read and write excel files.

The problem i'm facing right now is, when i run the application on my corporate network, i can't create any excel files. Although if i create an excel file using MS excel and try to read and write to it using my application, it works just as it should.

OBS!!! I'm using the same version of MS excel on both my PC and corporate pc.

My Q. is, could this(Can't create, but can read and write) be something that have to do with the user rights on the cor. network?

DreamNet
  • 627
  • 3
  • 8
  • 24

2 Answers2

0

I'm certain it's permissions. If the path is not right this will even happen when using winform and wpf apps on newer OS's.

Try creating and using the "Special Folders" for the files.

System.Environment.SpecialFolder.ApplicationData etc.

See As a developer, how should I use the special folders in Windows Vista (and Windows 7)?

and I recommend looking up special folders on MSDN. I ran into a similar issue a while back and now I always think about UAC when starting a new project.

Community
  • 1
  • 1
DaveCS
  • 950
  • 1
  • 10
  • 16
  • Thanks for the answer, do you mean permissions given to me via Admin? and btw sry i wasn't that clear in my Q. At home i use windows 7 and at work i use windows xp. When it comes to the application, in my code i used Enviroment.SpecialFolders.Personal in order to create/read/write the file in 'My Documents'. Creating the file gives me an error, while if i create the file using MS Excel and put it in 'My Documents' i can easily read and write to it. – DreamNet Jul 07 '12 at 04:10
  • 1
    With excel it's easy but the file creation is the problem. I use Dim UACSAFEEDIR = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) Try that I don't have a problem if my folders and files end up as such C:\Users\Dave\AppData\Roaming\someapp – DaveCS Jul 07 '12 at 13:16
  • Hi Dave, i tried your suggestion and did some tests, but still i'm running into the same problem. I asked my system admin to install and run the App för me and she couldn't run it. Any idea why is that? – DreamNet Jul 11 '12 at 19:46
  • Not sure. If they ran it as administrator and it still didn't run could it be a blocked assembly or an empty try catch? That's strange, I have a pretty tightly configured win2008 server and I can run most things from just logging in as admin. Wish I could help more – DaveCS Jul 12 '12 at 16:20
0

Let me summerize the problem i was facing before i answer my own question.

I'm working on a silverlight application that uses Excel COM automation in OOB to create/read/write excel files. The application was working perfect on my PC running windows7, both when debugging and while running. When i tried to run my application on my corporate network (All the PCs there uses Windows XP), i was not able to run it. So to solve this issue i went through the following:-

  1. I contacted the system Admin at my corporate to give me a higher privileges, he did BUT couldn't run my application. (Failure)
  2. I tried to change some of the code in my application like System.Environment.SpecialFolder.Personal to System.Environment.SpecialFolder.ApplicationData. Guess what? another Failure :(
  3. Lastly i ran the application on another PC i have at home that have Windows XP, and guess what? it RUNS. But why not on my corporate PC???
  4. NOW i think i know what is the problem. I Managed to repro the problem and solve it on my home Windows XP PC. Will try to test it at corporate next week.

The whole problem is solve by these steps:-

  1. Go to Administraive Tools.
  2. Find Component service and open it.
  3. Browse to DCOM Config.
  4. Find Microsoft Excel Application, right click and select properties.
  5. On the Security Tab, change the Launch and activation permission to Customize.
  6. Then add permissions to the user.

After that you are set to launch ;)

You can also read this for more info:- Microsoft Excel Application entry missing in DCOMCNFG

I will update this thread after i have tested this on my corporate PC.

Best regards

DreamNet
  • 627
  • 3
  • 8
  • 24