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
"Requested registry access is not allowed" shows up as inner exception. TypeInitialaztionException.
Gives better information...
Hello Henrik,
Thank you for posting in our forum.
What we found is that our Word engine use FileStream with FileMode parameter set as OpenOrCreate, while same parameter in Excel engine is set to Create. To test if this rise the exception you are receiving I have implement a small sample project. This project creates two text documents. First with FileMode set to OpenOrCreate and second with same parameter set to Create. Please run this sample and try to create this two files on your server. Please let me know if you receive the same exception.
Please note, in order to be able to investigate this issue in deeper details I will need a little bit more information
- Can you send me the entire exception stack?
- From your post I have understood that you were able to create the Word file on your server. You received the exception after the file was created. Is this correct?
Waiting for your feedback.
Both your tests work as the should, as well as the excel writer. But as you can see, the word writer fails.
The word file is created but if throws an exception. The stack trace can hopefully give you some clues...
/H
I am just checking about the progress of this issue. Let me know if you need my further assistance on it.
Thank you for using Infragistics Components.
Hello Miko!
Sorry for my late reply. I haven't had time to look at this problem since I am in the final stage of my project.
I will investigate when I have time and post you the feedback.
Thank you for your feedback
Please do not hesitate to contact with us if you have any further questions on this.
Thank you for using Infragistics Controls.
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?
It works like a charm, thanks Milko!
Thank you for your feedback.
So we have check this in much deeper details. What we found is somehow, the .NET framework is able to assert for registry read permissions (within the MS.Utility.EventTrace.IsClassicETWRegistryEnabled method) on the HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics\ registry key, but then it is not able to actually read from that location. So something very odd is going on.
Looking around on online, it appears that many of the people experiencing an error in the same stack trace are also in an impersonated user scenario. So, we think this is probably a bug in the .NET Framework when doing user impersonation. Trying to disable tracing will not help work around this issue by the way, because the error is happening in the static constructor of the class that checks whether tracing is enabled, so it never gets to the point of checking. So please do not try to change your app.config file.
What we found as a workaround is to force the static constructor of the tracing class to get executed before the user impersonation is done. This bypasses the bug in the .NET Framework. To do so we have added this code exactly before the user is impersonated:
Dim m As New MemoryStream()Dim p As System.IO.Packaging.Package = System.IO.Packaging.Package.Open(m, System.IO.FileMode.Create)p.Close()m.Close()
With this piece of code added it successfully have created the xlsx file at my server.
Please let me know if you need any further assistance.
Milko, any news in this topic?
No, I am not using any service. And sorry for not succeeding with this explanation ;-)
We have s standard file server in our company network. In a folder on this server (which is specific for this application), I have assigned something that I calla service user fulls rights to this folder. This user has modify right to be exact. I myself only have read access.
So to be able to create a file in this folder when I am running this application, I must use this "service user", since I don't have right to do that by myself.
When I run the application on my computer, my user is the one that is executing it, so all operations that are done from this application is done by "me" as standard.
Is Everything clear now?
“When I am creating the file on the server, I am doing it using a dedicated service user”
If I understand you correctly you are consuming some services in your Windows Forms application in order to create a user on the server and to export the file. You need to check the web.config of the application which manages this service. There you may find the trace listeners. Please check this application, and not you Windows Forms application, and try to remove the tracing.
Looking forward to your feedback.