Hello!
I have just started to work with the Infragistics.Documents.Word namespace.
I tried to create a simple document using the following code:
Dim doc as new Infragistics.Documents.Word.Document
doc.save(filename)
This code creates a file but it also generates an exception. The exception is of type
"The type initializer for MS.Utility.EventTrace threw an exception"
I have implemented code that creates some text inside the document but that isn't included when it is saved. So something is wrong.
I am creating these files on a server with special rules of accesscontrol.
I am pretty sure that this has something to do with the server settings and not the Infragistics tools, but with an
exception like that, I am totally lost.
Someone out there who understands the problem?
/Henrik
Hello Miko!
Finally, I have found some interesting things for you. I had a long discussion with our service desk and we tried a lot of different scenarios.
When I am creating the file on the server, I am doing it using a dedicated service user:
First, I log on with the service user, I call impersonate, and last of all I create the file. Something like this:
If LogonUser(ConfigFS.ServiceAccountUserID, ConfigFS.ServiceAccountDomain, ConfigFS.ServiceAccountPassword, 2, 0, tokenHandle) Then
Dim newId As New WindowsIdentity(tokenHandle)
Using impersonatedUser As WindowsImpersonationContext = newId.Impersonate()
What I tried was that I added the service user as local admin on my computer, and that worked.
This means that the user that creates the file on our server must be local admin on the computer executing the application.
This seems to be needed for xlsx files, but not for XLs files.
I hope that you can verify this scenario.
Perhaps this is normal, but I don't understand why different file types behave differently.
Hi Zlatan,
In order to be able to try to investigate this further can you please give us more information regarding your scenario:
1. What is the environment on your developer machine where the application is running?
2. What is the environment on the server where you are trying to save Word and Excel files?
3. Can you save the files at your local machine?
4. How you are access the server?
Looking forward to your reply.
The exception looks the same as Before and I have posted it in a previous post. It looks like this.
Exception: The type initializer for 'MS.Utility.EventTrace' threw an exception.
ex.StackTrace.ToString " at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID) at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming) at Infragistics.Documents.Core.Packaging.PackageFactory.Open(Stream stream, FileMode packageMode) at Infragistics.Documents.Word.WordprocessingMLWriter.Open(Stream stream, IPackageFactory packageFactory) at Infragistics.Documents.Word.Document.SaveHelper(Stream stream) at Infragistics.Documents.Word.Document.Save(String filename) at XBOW.DB.FileManager.CreateOffer() in C:\Users\LPHB\Documents\Visual Studio 2010\Projects\XBOW\XBOWclient\Classes\General\FileManager.vb:line 662" String
I understand if you have problems repreducing it on your side. I am just fishing for some sort of hint that can solve it.
The excel workbook format is sent into the export function.
I have two different scenarios that I am testing, one works and one doesn't:
Workbook format 97-2003, filename ending with .xLs = working!
Workbook format 2007, filename ending with .xlsx = not working!
strange...
/Henr
Hello Henrik,
Thank you for your feedback
Regarding the MS Word documents please check if you have the necessary permissions on the server. The exception you are receiving is thrown by MS.Utility.EventTrace and as we cannot reproduce it at our side we cannot investigate it further. Please try also to check the inner exception of this exception as it may give us additional information.
Regarding the Excel export to xlsx format in Export method you need to specify the WorkbookFormat. More about this overload of Export method you may find by following the next link http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=Infragistics4.Win.UltraWinGrid.ExcelExport.v15.1~Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter~Export(UltraGrid,String,WorkbookFormat).html
Looking forward to your feedback.
Now I have some updates for you. Today, I updated my components to the last service release available. I am using 14.2.
The error message is still the same, so I guess that we can stop focusing on an incomplete installation.
Currently, I am using Microsoft Word Interop for the Word documents, and that works with both .doc and .docx files.
For excel, I am using your UltraGridExcelExporter, and that works for .xls and 97-2003 file-format, but not for .xlsx and 2007 file format.
When you have an UltraGrid, and using the export functionality, what compenents are needed for that to work?
I have Documents.Core, Documents.Excel, WinGrid, WinGrid.ExcelExport and shared, win.misc and win.
Ideas?