Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

When I am saving a file on my server using asp.net application, it gives me "Access Denied", but I don't have the case on my localhost server.

knowing that I gave all users full permissions.

I use the word.application to save my file.

 

Dim WordApp As Word.ApplicationClass = New Word.ApplicationClass()

Dim aDoc1 As New Word.Document()

aDoc1.Activate()

aDoc1.Content.Text = FileContent

aDoc1.SaveAs(fileURL)

WordApp.Quit()

aDoc1 = Nothing

WordApp = Nothing

 

any help please.

Thanks in advance.

Posted
Can I have the content of the variable fileURL ?

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted (edited)

Function called ???

 

First ... make sure the file isn't already open by another Word. If you don't deallocate memory from Word objects, Word won't close correctly and will still have your document opened if you haven't closed it.

 

Here is the function the clear them from memory.

 

Private Sub Nars(o as Object)
Try 
  System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
Catch

Finally 
   o = nothing
End Sub

Edited by Arch4ngel

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted
In your exemple, you must do : NAR(aDoc) before quitting or it won't close.

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

  • Administrators
Posted

Which line of code actually generates the error? It may be a problem instantiating an instance of word.exe. I think you will need to grant permissions for aspnet to launch the application.

 

If you are running XP (and I think win2k and win2003) this should work. Start->Run->dcomcnfg - this should launch the component services tool.

Drill down to the correct computer and select DCOM config.

Look for the package that corresponds to MS Word (think it is called either 'Microsoft

Document' or 'Microsoft Word Document').

Right click on it and bring up the property pages, then go to the security tab. Under launch permissions select customize and then edit. Finally add in the \ASPNET account.

 

Not 100% on all of the above (don't have word or VS installed here) but it should be close enough to get you looking in the right direction.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

I do what you suggested but nothing happen.

I want to inform you that when I used the streamwriter to save the file,

everything is fine and no "access denied " error.

But I cannot use it because streamwriter doesn't allow me to customize my document (font family etc.....).

So what I thing that is a problem between word and the MyServerName\ASPNET account.

what do you suggested?

thanks in advance.

  • Administrators
Posted

Quick search on google only brought back one hit - may be worth having a look at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office10032002.asp

 

Out of interest does the server have the same version of word as your development box?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Even though the aspnet account has write rights you still need the IUSR_<machinename> to have write rights to the directory.

You might even try impersonation that allows the app to run inthe same user context as the account its impersonating instead of the asp app domain.

 

Also did you change your machine.config to reflect the system process type to system instead of machine ??

 

C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\CONFIG\machine.config

 

ie

<processModel
           enable="true"
           timeout="Infinite"
           idleTimeout="Infinite"
           shutdownTimeout="0:00:05"
           requestLimit="Infinite"
           requestQueueLimit="5000"
           restartQueueLimit="10"
           memoryLimit="60"
           webGarden="false"
           cpuMask="0xffffffff"
           [color=Red]userName="machine"[/color]
           password="AutoGenerate"
           logLevel="Errors"
           clientConnectedCheck="0:00:05"
           comAuthenticationLevel="Connect"
           comImpersonationLevel="Impersonate"
           responseRestartDeadlockInterval="00:09:00"
           responseDeadlockInterval="00:03:00"
           maxWorkerThreads="25"
           maxIoThreads="25" />

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...