You could also - depending on the RDBMS - store the PDF as a binary stream, which some ADO.NET classes (like those in System.Data.SqlClient) support. IMO, you should store the PDF on the filesystem and either store the path in the DB or use the primary key as part of the filename, which is what we do in our flagship product.
I'm using the ".NET Configuration Tool" to change the properties of the permissions belongin' to various permission sets. This can be done using the "Properties" dialog available for any built-in permission.
Is there any way to provide such a dialog for a custom permission, a CodeAccessPermission-derived class? The default displays a message like "The Custom Permission is unrestricted", or an xml fragment
The mscorcfg.dll assembly for the Microsoft .NET Framework Configuration snap-in is hard-coded to display views and property pages for the built-in permission classes and all the abstract classes are marked private. There is nothing in the .NET base class library for this either, unfortunately. You could take a look at the aforementioned assembly to see if there's any other hooks or interfaces, but it doesn't appear to have any.
If I open a form with a axwebbrowser-control in a mdi-container
and show an excel-sheet in the webcontrol, than close the form
and application, the excel-process leaves alive.
If I close the application without closing the form first
The environment variable has to be a system environment variable, or a user environment variable for the user that the service runs as. Adding environment variables from the command-line are also only valid for that instance of the command line, or any programs started from the command line. To configure persistent, global environment variables, go to the Advanced tab of your System Properties (right-click on My Computer and select Properties) and click the Environment Variables button (or similar). You'll see sections for both user and system environment variables there.
There is preproc conditions supported by the C# compiler, yes, but there is no such definitions provided by the compiler that are documented, so you'll have to pass them yourself using /d:SYMBOL or configuring additional symbols in your VS.NET project (go to project properties, expand Configuration Properties, click on Build, and add symbols to the Conditional Compilation Constants at the top). An example follows:
Drag and drop is not trivial to implement. .NET exposes this in a rather easy-to-use method that encapsulates all the native functions, interfaces, structs, and enums/constants. As you can see, though, not every control in .NET supports drag and drop, either. There is a lot that has to be done in order to do this for native windows. There is more documentation in the Platform SDK at http://msdn.microsoft.com/library/en-us/dnanchor/html/anch_WinShell.asp[^]. Specific interfaces and functions to look at are IDropSource, IDropTarget, IDataOject, and DoDragDrop. These are all from the Platform SDK, not the .NET Framework SDK (I only mentioned because a couple of these have similarly named equivalents in both). Those four interfaces and functions - along with the documentation about them - should be enough to get you started.
On a side note, so long as the clipboard formats are supported by both the drag source and the drop target - regardless whether either one is managed or native - and the data is formatted correctly you can drag and drop between windows.
Finally, if you are looking to add drag-n-drop support to your native Windows, first read about the Windows Shell and drag-n-drop interfaces from the link I gave you and continue in the Visual C++ or ATL/WTL/STL forum.
I would like to improve my application; hope it can minimize to system tray, and appear again if double clicked on system tray icon.
I know I should use notify icon, but how can I catch the minimize event of my application and tell it to minimize to system tray?
I just hope to find a good example of using notify icon, could any one help and teach me?
Well it may seem that the application is actually minimizing into the system tray. But what happens is that when you minimize your application you actually hide it. Then when you double click on the notify icon, you show the application in its normal state.
// This hids the application when Minimized. (Forms resize event)
private void frmMain_Resize(object sender, System.EventArgs e)
if (this.WindowState == FormWindowState.Minimized)
// Show the application when doubleclick event happens (Icon Try Double Click Event)
private void nicTray_DoubleClick(object sender, System.EventArgs e)
this.WindowState = FormWindowState.Normal;
It works like your expection, but the visual effect looks strange,; it firstly minimized to left bottom corner and then hide, that means always flash to left corner and then restore. How can I minimize it directly to system tray?
Through so much unbelievable math it's not even funny! The minimization effect is handled by the Windows, not the application. You have to dig very deep into Windows to override that behavior (if possible) and do all the math yourself to draw the minimizing Window compacting and moving toward the systray icon. I've never seen an application do this - not even from Microsoft.
What I do so most often to combat this effect is to hide the window first, then minimize, or vice-versa to restore (restore then show). This way, you don't see the Window minimize and don't have to worry about such behavior (which I agree looks odd).
I've run into a situation I haven't seen before, and was wondering if someone with a bit more threading experience would like to chime in.
The class IsoCurrencyInfo maintains a collection of IsoCurrencyInfo singletons. The instances of IsoCurrencyInfo class themselves are read-only once created, so by themselves are thread-safe. The trick is keeping the ArrayList container in line. I think I have it nailed, but in doing so I am executing a return statement while inside a lock().
The code works very well under heavy concurrent load , but I can't help wondering "Is this safe?" Is there a better way to structure this method to optimize the locking?
The finally block is always run - regardless of a return or a throw - except when Environment.Exit is called (which unloads the process and the CLR completely, thus it really won't matter that the lock wasn't released because the OS will reclaim any process resources).
I don't necessarily see anything incorrect about your implementation. However, the double-checked locking pattern is essentially useless as you have used it since you'll always be aquiring at least one lock anyway. I would suggest the following code...
privatestatic Hashtable _iciRegistry = new Hashtable();
publicstatic IsoCurrencyInfo GetInstance(string isoCode)
_iciRegistry.Add(isoCode, new IsoCurrencyInfo(isoCode));
It is important to realize that the Hashtable is the only IDictionary collection that will work as I have used it. This is because the Hashtable can support multiple readers and one writer simultaneously. Likewise, you won't be able to use the same trick with an ArrayList. In this implementation the lock is rarely acquired.
Based on your code and some thought, I ended up restructuring the entire class. It is smaller, tighter, and a lot faster. My test suite execution time dropped from an average of more than 500ms to less than 200ms; it drops to less than 1ms when I pre-load the singletons. That lock-loop was killing me.
hai everybody... may i know how to write the coding for the log off, reboot and shut down function in C# language. The coding must be able to use own pc so such to control others pc... I got a sample code which is written in VB6 as below:
Private Sub butLogOff_Click()
Private Sub butReboot_Click()
Private Sub butShutdown_Click()
Select Case task
cmdValue = CONST_LOGOFF
cmdValue = CONST_REBOOT
cmdValue = CONST_SHUTDOWN
Set objEnumerator = objService.ExecQuery("Select * From Win32_OperatingSystem", , 0)
For Each objInstance In objEnumerator
intStatus = objInstance.Win32ShutDown(cmdValue)
If intStatus = 0 Then
ShowStatus "System Function call successful."
ShowStatus "System Function call failed!"
Last Visit: 31-Dec-99 19:00 Last Update: 27-Jan-23 21:27