|
I want to add a Custom Options tab in MS word using Add-Ins. I referred to DOM of word but didnt find any useful information for that. can anyone suggest how it can be done
Javed Hussain
Software Developer
GoNetBPO.
|
|
|
|
|
Hi! As many on these forums I'm using a familiar scenario for
FileSystemWatcher where it's sitting in Windows Service (written in Vb.net)
and watches for some files either on local or remote machines to arrive and
to be processed. First off quick overview of how my app works. Windows
service polls SQL database for files/locations to watch and perform certain
actions when those files arrive. For each of the rows in the SQL db I create
a new instance of FileSystemWatcher with all properties set accordingly. I
then add this instance to a global hashtable declared on the service level.
When the event fires (I now watch for OnChanged/OnCreated events) I compare
the source object that fired with what's stored in hashtable and if one is
found I perform the actions associated with that filesystemwatcher object.
Thus far in my testing I have not dealt with more than 8 files that might or
might not be created at the same time, but it seems that for some reason my
FSW objects randomly skip/ignore the files that are being written without
throwing any errors. The weird thing is that sometimes it can process the
file that it ignored 2 hours later or if I monitor the transaction and see
that it did not pick up the file that I know it was watching I just copy and
paste same file in the same dir and it then picked up by filewatcher. I have
read a lot of posts on this subject and everything points to the buffer
overflow issue where FSW skips the calls when too many events are raised.
But I'm only watchin so few files so I'm not sure why this would be
happening. I also tried increaseing the buffer 4 fold which did not help
(the default is 4k). I'm now attempting to increase it by 8, but I don't
think that's a good solution. Any suggestions as to how I can make sure FSW
is consistently picking up the files would be greatly appreciated.
|
|
|
|
|
Hi
Does anybody know how to get the AccessibleContext from window handle using the API:
bool GetAccessibleContextFromHWND(HWND windowHandle, long *vmID, AccessibleContext *ac);
In the above API,
1. what *ac stands for? With what can I replace that pointer in C#?
2. Is AccessibleContext a structure or can I just use a System.Object to represent *ac ?
Please help me with smple codes in C#
thx in advance..
|
|
|
|
|
I am having trouble with my VB.Net code while trying to run a SELECT-query with a "WHERE" clause on an MS Access table with some relationship specified. The same code runs fine when it is run on a table that has no relationships specified on it or if there is no "WHERE" clause. The code I am using is
Dim cmd As New OleDbCommand("SELECT * FROM Language_master WHERE Language_master.Language='English'", myConn)
Dim DtRd1 As OleDbDataReader
myConn.Open()
DtRd1 = cmd.ExecuteReader()
While (DtRd1.Read())
MessageBox.Show(Convert.ToString(DtRd1.GetValue(0)) + " " + Convert.ToString(DtRd1.GetValue(1)))
End While
myConn.Close()
the MS Dvpt Environment throws up "An unhandled exception of Type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" error at the cmd.ExecuteReader() line.
The same code runs fine when I use another table "LibUser_Master". The only difference betwen the tables is that "Language_master" has some relationships specified on it, whereas "LibUser_Master" has none.
And the same code runs fine on both tables when the select query has no "WHERE" clause or if the "WHERE" clause is for a number field.
Can anybody help me solve this problem...
|
|
|
|
|
Okay I'm not a pro but.. I would try with changing your SQL a bit.
Do you really need to select all columns in Language_master?
Select those you need. It could help.
|
|
|
|
|
Hi everyone, I need somehow to prevent other developers from creating threads in the applicationdomain created by me. the concept is an applicationdomain working as a manager for plugins made by others..
many thanks!!
|
|
|
|
|
Hi all.
Is there a way to check if a file has been digitally signed and has attached digital certificate and then if so extract it so it can be used on the code.
I know there is a tool called secutil. How can I use it from command line?
Any other ideas? Please help.
izabela
|
|
|
|
|
Hi
I want to edit a column in a datagrid dynamically.
Eg: If I have 5 columns in datagrid say A, B, C, D and E. And another parameter say X has value 3 which tells me to edit column C. Like this I want to edit the columns dynamically based on the value from X. Other columns should be non-editable but visible.
Any ideas will be helpful...
Thanks
Sundar.
|
|
|
|
|
We have several applications that will be executing on multiple machines. These applications will be placed on our network and setup with an xcopy style of deployment. To accomplish this task, we had to adjust the Framework configuration, Code Access Security for the machine to Full Trust for Local Intranet applications.
We created a deployment package and we execute this on any machines that will execute the apps.
These apps also have a feature where we write messages to the eventlog when an error is encountered. This works great for our clients that have Power user or admin rights, but for a standard user the eventlog post fails with a message that "Requested Registry Access is Not Allowed".
There are Permission Sets within the framework configuration tool, but I'm not sure what the best approach is to accomplish allowing standard clients the permisiion to write to the eventlog without opening security up too much.
Any suggestions would be appreciated!
Lost in the vast sea of .NET
|
|
|
|
|
There are two things we do to write to the eventLog.
1) Before calling our function to write to the eventLog create a new System.Diagnostics.EventLogPermission(PermissionState.Unrestricted) and call assert on it. NB// remember to call revertAssert when the call has completed. This gives the code full permision to write to the event log.
2) The main reason code fails to write to the event log is because it has insufficient rights to create an event Source for the log entry. To get round this we catch the exception thrown by CreateEventSource and set the event source to "Application Error", which has already been created by windows.
With these two together we have avoided errors writing to the event log regardless of the current access rights.
One further possibility we tried, which works but is inflexible is to create the event source (and for our app, a custom event log) during the installation process, as you must have admin rights to install the app anyway. then at runtime the only rights required are the ability to write to that particular event log.
|
|
|
|
|
I've had this question out on several message boards and I even currently have an open MSDN call with Microsoft trying to come up with a solution. You're message is the most promising solution I've heard of yet. Thanks!!
Everyone else wants to hack the registry and change settings on each client's pc everytime we hire a new employee or change pc's. Like you mentioned, this is inflexible and much more maintenance oriented.
Can you post a few code samples of the EventPermission code and the event source code?
Thanks again for your feedback!!
Lost in the vast sea of .NET
|
|
|
|
|
Here is the code we use in VB.Net (at least the Event log bit of it). If you prefer C# let me know and I'll post a C# version.
Imports System.Security
Imports System.Threading
Imports System.Environment
Imports System.Security.Permissions
Public Class EventLogService
'''-----------------------------------------------------------------------------
''' <summary>
''' Error message to be thrown if access is denied.
''' </summary>
'''-----------------------------------------------------------------------------
Private Const EVENTLOG_DENIED As String = "The event source {0} does not exist and cannot be created with the current permissions."
'''-----------------------------------------------------------------------------
''' <summary>
''' Publicly exposed method to create event log entries.
''' </summary>
''' <param name="text">The text of the log to create.</param>
''' <remarks>
''' This attempts to create an entry in the WestwoodForster event log
''' using the current AppDomain Friendly name as the event source name.
''' If this cannot be done for any reason then the entry will be created
''' as an 'Application Error' in the Application event log.
''' Additionaly a check is performed so that is event logging is not supported,
''' such as on Windows 98, no action is performed.
''' </remarks>
''' <history>
''' [mjackson] 19/07/2004 Created
''' </history>
'''-----------------------------------------------------------------------------
Public Sub CreateEntry(ByVal text As String)
Dim eventlogPermission As New System.Diagnostics.EventLogPermission(PermissionState.Unrestricted)
eventlogPermission.Assert()
Try
Me.writeEventLogEntry(text)
Catch ex As PlatformNotSupportedException
End Try
eventlogPermission.RevertAssert()
End Sub
'''-----------------------------------------------------------------------------
''' <summary>
''' Internal method to write to event log.
''' </summary>
''' <param name="text">Message to log.</param>
''' <remarks></remarks>
''' <history>
''' [mjackson] 19/07/2004 Created
''' </history>
'''-----------------------------------------------------------------------------
Private Sub writeEventLogEntry(ByVal text As String)
Dim eventsource As String
eventsource = AppDomain.CurrentDomain.FriendlyName
Me.validateEventSource(eventsource)
Try
EventLog.WriteEntry(eventsource, text, EventLogEntryType.Error, 1000)
Catch e As SecurityException
Throw New SecurityException(String.Format(EVENTLOG_DENIED, AppDomain.CurrentDomain.FriendlyName), e)
End Try
End Sub
'''-----------------------------------------------------------------------------
''' <summary>
''' Internal method to validate or create event sources.
''' </summary>
''' <param name="eventSource">The name of the event source to create.</param>
''' <remarks>
''' Defaults to 'Application error' if could not be created.
''' </remarks>
''' <history>
''' [mjackson] 19/07/2004 Created
''' </history>
'''-----------------------------------------------------------------------------
Private Sub validateEventSource(ByRef eventSource As String)
Try
If Not EventLog.SourceExists(eventSource) Then
EventLog.CreateEventSource(eventSource, "CustomEventLog")
End If
Catch e As SecurityException
eventSource = "Application Error"
End Try
End Sub
End Class
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
My last post got me thinking and I did some retesting of our code.
It seems the EventLogPermission.Assert makes no difference. We got lucky because most times the source got created by a Service we are running under a the SYSTEM account. The rest of the time everything was falling into the "Application Error" catch. This gives a bit of a messy message but at least you get one. We hope to have very few errors, if any, to log, but that is living in hope.
In search of a better solution I did some tests and everything runs afoul of the Operating System ACL's with no way round it.
I have thought of two possible solutions that I will be trying.
1) Run a separate Windows Service just to log errors under the SYSTEM account.
2) Impersonate the SYSTEM account in code.
This second option I have managed to use with a hard coded username and password, which isn't much use for a wider deployment, but may be a step in the right direction.
Public Overloads Shared Sub WriteMessage(ByVal message As String, ByVal source As String, ByVal log As String)
Dim password As String = "****"
Dim username As String = "****"
Dim tokenHandle As IntPtr = IntPtr.Zero
Dim returnValue As Boolean = LogonUser(username, System.Environment.MachineName, password, 2, 0, tokenHandle)
Dim impersonatedUser As WindowsImpersonationContext = WindowsIdentity.Impersonate(tokenHandle)
Try
CustomEventLog.InternalWriteMessage(message, source, log)
Catch ex As PlatformNotSupportedException
End Try
impersonatedUser.Undo()
End Sub
Private Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As [String], _
ByVal lpszDomain As [String], ByVal lpszPassword As [String], _
ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, _
ByRef phToken As IntPtr) As Boolean
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
Bother.
You can only impersonate if you have impersonation privileges as per the article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncode/html/secure03132003.asp[^]. This says that the ability to impersonate is only granted to accounts with the Service SID (Network Service, Local Service, and Local System) and Administrators.
If you are one of those you can write to the registry anyway so no point in impersonation!
So we are back to making use of an existing source, or creating your own source in the installer package.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
I received notification on your original response with the code samples via e-mail, but after that message I was not notified and didn't see the additional info you posted... Sorry.
I did however plan to follow-up with what we found:
1) Security is the hitch when a standard client tries to write to the registry. The app searches for the eventsource and when it cannot find it, tries to create one. Due to the rights, it fails and causes our error.
2) We have a class that we wrote for use in our shop, which can be referenced in any program, and if called, can display a message box, write to the eventlog and e-mail, depending what parameters are set. We took a sample of the code you posted and we check if the event source is there. If not, we try to create the event source. If the create fails we notify the client that they need to call us and run a process we call DeployEventSource.
3) We wrote an app (DeployEventSource) which creates the eventsource and is basically setup to be installed by our team with admin or power user rights. We wanted to try to to eliminate as much maintenance as possible and I believe we accomplished this goal. Since our class above writes to a source name that we keep consistent, and our install / create source program creates a source with the same name, we only have to run the install app when someone gets a new machine or system reload. If profiles change with terminations / new hires, we do not have to keep reinstalling or hacking a registry setting. Also we can create several apps that run on this pc which uses our class to write to the eventlog, and as long as the eventsource was created once, it will work for all apps.
You pointed us in the right direction and I really appreciate all your help and continued testing.
Thanks again!!
KreativeKai
Lost in the vast sea of .NET
|
|
|
|
|
Hi people!
I'm using OleDbDataReader to get rows one-by-one from Excel sheet. The
code I'm using to do this:
oConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + name +
";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\"");
oConn.Open();
OleDbCommand oCmd = new OleDbCommand("SELECT * FROM [Sheet1$]",
oConn);
OleDbDataReader oReader = oCmd.ExecuteReader();
while (oReader.Read())
{
//array to store current row
object[] rowValues = new object[oReader.FieldCount];
oReader.GetValues(rowValues);
.....
}
Parameter TypeGuessRow=0. So the problem I'm getting is: values from
column with mixed types is imported with loosing their precision! For
example I have column with values {'9133.13', '87654321', '586472.12',
'a.27'}. First value imported correctly, second and third - are not.
For second I got 8.76543e+007 and for third I got 586472. Fourth value
is also correct. Firstly these cells has "Currency" format, but after
it was changed by user to "Text" without reentering values to the
cells. After this changes my problem had arised. May someone knows how
to fix it - any comments/advices/links appreciated.
|
|
|
|
|
Hi,
I've implemented global mouse and keyboard hooks in C#, however, once I set the hook type to WH_CBT and run the application, an ugly black command prompt screen prompts out saying there was an error in CLR at runtime
Has anybody been able to implement system-wide CBT hooks in any .NET language?
If I keep getting stuck in this, can I make a c++ DLL that does all the hooking and use it in my C#/VB.NET app?
Thanks
|
|
|
|
|
I have a web service client that is written in VC++.net and needs to connect to different application servers(dev, test, and production).
When this application starts a user is presented with a dialog box asking for their username and password. I also need to add the server to this dialog box.
I have created the call to the web service, using the "Add Web Reference" wizard and browsing to the WSDL document. Is there any way at runtime to have the client choose which server to connect to?
Josh Angolano
|
|
|
|
|
Does anyne know how to connecto to Lotus notes using asp.net or a data provider to do that.
thanks.
.]
|
|
|
|
|
|
Thanks Kevin I really apreciate your help baut that object is only freeware for 30 days, don't you know something that is free.
|
|
|
|
|
No, I don't. Can you follow the same principles and use the OleDb provider?
Kevin
|
|
|
|
|
Do you know where can i see how to do that.
Thanks for your time.
|
|
|
|
|
I'm not familiar with Lotus Notes, I just did a Google search for Lotus Notes Data Provider. I assume you could copy the example they have there and replace the provider with the .NET OleDbProvider. But maybe it's not as simple as that? Have you tried a Lotus Notes discussion forum?
Kevin
|
|
|
|
|
Can I ask for some advice.
I am currently running Visual Studio 2002 (7.0) and have noticed that Microsoft are giving away Visual C++ Toolkit 2003.
I was trying to use mySQL++ API, but I need to upgrade to VS2003 (7.1).
So my question can I downoad this toolkit and build a VS 7.1 project?
I have looked at the documentation and I am a bit confused?
i.e. how does the VS IDE fit into this Visual C++ Toolkit 2003.
|
|
|
|