|
Hi,
I have a C# windows application, say, Launcher, which is started with a privileged user’s credential. Can someone pls suggest how would I be able to capture the logoff event from the Launcher application when a user (not the privileged user) logs off or shuts down from windows, using C#? It would be great if the solution could work in both desktop and terminal server environments.
Regards
MPR2006
|
|
|
|
|
You could try the SystemEvents.SessionEnding event, but I'm not sure whether it is invoked for any user or only the one running the application.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
As you rightly doubt, SystemEvents.SessionEnding does not work if application is running with another (privileged) user's credential.
|
|
|
|
|
What I've done is create a DLL which when added to the registry, logs the log on and log off events. The information to do this is in the platform SDK documentation under WLX. Please note that you do not have to write a replacement for GINA to get this to work.
Phil
|
|
|
|
|
Hello everyone,
I went thru the article Assemblies: locating, binding and deploying written by Mr. Cohen Shwartz Oren. It is indeed informatory and useful. But i have a problem in C# assemblies. I developed a dll and strong named it. Now i want to use it in an application in another machine. So i wrote the app.config file and given the codebase in that....but the applicaition searches the local directories and the machine.config file and it is not using the path given in codebase. i tried doing it from an application in the same machine also changing the location of dll. but its not working. i think the app.config file is not at all checked.can u pls help me...
the following is my xml code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentassembly>
<assemblyIdentity name="lib"
publicKeyToken="707ce16eaddaa550"
culture="neutral" />
<codeBase version="1.0.2622.27241"
href="file:///mca-oa2\beuls\c#\lib\lib\bin\Debug\lib.dll"/>
</dependentassembly>
</runtime>
</configuration>
Any help is greatly appreciated.
Thx.
Beulah
-- modified at 4:54 Monday 12th March, 2007
|
|
|
|
|
Your XML code is only partially visible. You should modify your post by either enabling the "Ignore HTML tags in this message" beneath the smilies or replace < with <
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank u...i have modified
-- modified at 5:01 Monday 12th March, 2007
i am also adding the details from the JIT debugger...hope it is more useful... the prob i think is that the machine.config file is searched instead of locating app.config file...
System.IO.FileNotFoundException: File or assembly name testLib, or one of its dependencies, was not found.
File name: "testLib"
at test1.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
=== Pre-bind state information ===
LOG: DisplayName = testLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20dbb001a9e43121
(Fully-specified)
LOG: Appbase = C:\MyTest\test1\test1\bin\Debug\
LOG: Initial PrivatePath = NULL
Calling assembly : test1, Version=1.0.2627.26008, Culture=neutral, PublicKeyToken=null.
===
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: testLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20dbb001a9e43121
LOG: Attempting download of new URL file:///C:/MyTest/test1/test1/bin/Debug/testLib.DLL.
LOG: Attempting download of new URL file:///C:/MyTest/test1/test1/bin/Debug/testLib/testLib.DLL.
LOG: Attempting download of new URL file:///C:/MyTest/test1/test1/bin/Debug/testLib.EXE.
LOG: Attempting download of new URL file:///C:/MyTest/test1/test1/bin/Debug/testLib/testLib.EXE.
|
|
|
|
|
Hi,
For Example:
In DataGridView I have three column and displaying in DataGridView like this:
TabNamePosition TabName TabText
1 SysParam Admin
2 Dev Developer
3 Job Job
What i want, during run time if I select 3 record and want to reorder the position of reocrds.
Like
I want 3 record in the 1st position and 1st record in the 2nd position and 2nd record in 3rd position.
after finished DataGridView should look like this
TabNamePosition TabName TabText
1 Job Job
2 SysParam Admin
3 Dev Developer
so,How to do
Plz help me out,Arrgent
Thanks
|
|
|
|
|
Hello everyone,
I have created a DVD Player windows application using C#. I am trying to get the Name of the DVD and display it the application. I am currently using the following code to get the name of the Disc:
SelectQuery query = new SelectQuery( "select * from win32_logicaldisk where drivetype=5" );
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach( ManagementObject mo in searcher.Get() )
{
// If both properties are null I suppose there's no CD
if( ( mo["volumename"] != null ) || ( mo["volumeserialnumber"] != null ) )
{
MessageBox.Show(mo["volumename"].ToString());
MessageBox.Show(mo["volumeserialnumber"].ToString());
}
else
{
MessageBox.Show("No. DVD in Unit");
}
The problem is that if I have a a CD in my CD-Drive and a DVD in my DVD-Driver, I am getting both's name and serial number. How can I make sure I only get the DVD?
Thank you so much for your help.
Khoramdin
|
|
|
|
|
Hello,
Infact I faced the same problem. I think it is recognizing drive type 5 as both CDROM/DVD rom .It is not making any difference between CD and DVD drive.for both drive type is 5.but wait for other GURU's reply
Regards,
nishu
|
|
|
|
|
How to Insert/Read a BLOB Field With DB2 DataBase?
|
|
|
|
|
SQLCommand sql_cmd = null;
//create a table with blob field
sql_cmd.CommandText = "CREATE TABLE blob_sample (image BLOB);";
sql_cmd.ExecuteNonQuery();
byte[] buf = new byte[1024];
//Read an image
FileStream file = new FileStream("debug.bmp", FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(file);
resStream.Read(buf, 0, System.Convert.ToInt32(buf.Length));
bw.Write(buf);
bw.Close();
file.Close();
//Insert the image in the database
sql_cmd.CommandText = "INSERT INTO blob_sample (image) VALUES (@image)";
SQLParameter parm1 = new SQLParameter();
parm1.DbType = DbType.Binary;
parm1.ParameterName = "@image";
parm1.Value = (byte[])buf;
sql_cmd.Parameters.Add(parm1);
sql_cmd.ExecuteNonQuery();
|
|
|
|
|
In my application, a few times the XML serializer just crash with exception like:
==================
Message : Timed out waiting for a program to execute. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /noconfig /fullpaths @"C:\Documents and Settings\SOTEC繝ヲ繝シ繧カ繝シ\Local Settings\Temp\xcul_mqt.cmdline".
at System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDirectory, String compilerExe, String arguments, String& outputFile, Int32& nativeReturnValue, String trueArgs)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, CompilerParameters parameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, CompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
==================
I wonder if any progress on these issues has been made in .NET 3?
|
|
|
|
|
Using MainMenu & ContextMenu to create a semi-transparent menu class. My question is when a menu group is shown it displays a ?shadowed panel? as the palette to display items. Is there any way to catch the draw message from Whoever draws the palette ?
Thanks,
Mike
-- modified at 20:45 Sunday 11th March, 2007
Started out with nothing and still have most of it left!
|
|
|
|
|
is it possible to create an object from a class in a VC++6 DLL from C# and call its member functions?
i know that i can call function from the Dll using Dllimport, but if these functions are member function in a clas ?
Thanks
MiNa
|
|
|
|
|
No, that's not possible. You have two options.
1. Make the VC++ DLL a COM DLL and use Interop to call it as a COM component.
2. Write a C++/CLI wrapper around the VC++ DLL and use the wrapper from C#. This would be the easier approach, IMO.
|
|
|
|
|
Do you have any links or articles that show the creation of C++ wrapper as i dont have any ideas about this stuff.
appreciate your help
MiNa
|
|
|
|
|
Is there a way to find out what reference is keeping alive an object after garbage collection?
|
|
|
|
|
The answer is none, if GC occurs, then it's because there is no reference to an object being kept alive.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
What if I issue GC.Collect()?
Can I get a list of the remaining objects?
|
|
|
|
|
No becuase even using GC.Collect() doesn't gaurantee collection, just implies that the GC should think about it.
|
|
|
|
|
That's incorrect, GC.Collect forces a collection immediately.
|
|
|
|
|
It won't give you the list of remaining objects, but it will force the GC to cycle through a collection. However, it is almost always a bad idea to call GC.Collect() yourself as it puts an undue burden on both your app and the GC.
Whenever the GC runs, it actually freezes the main thread of your application for the duration of the GC cycle. Making your own calls to GC.Collect() will end up causing more context switches and thread freezing/thawing than would otherwise occur and will actually end up hurting performance.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Scott Dorman wrote: It won't give you the list of remaining objects
Since it returns void and accepts no parameters I knew that.
Scott Dorman wrote: Whenever the GC runs, it actually freezes the main thread of your application for the duration of the GC cycle
and I'm clear with that too.
But I use for testing purposes GC.Collect. The question is how can I realize a list
like some memory profilers do? Not as detaliated but just the actual situation of some objects (if they still exists).
I don't know how too explain more clearly. Anyway I'm playing with a memory profiler to see the allocations/gc's.
|
|
|
|
|
Zoltan Balazs wrote: But I use for testing purposes GC.Collect. The question is how can I realize a list
like some memory profilers do? Not as detaliated but just the actual situation of some objects (if they still exists).
I don't know how too explain more clearly. Anyway I'm playing with a memory profiler to see the allocations/gc's.
I think using the memory profiler or looking at the various .NET related performance counters will be your best bet. I'm not sure how you would actually accomplish what you are after...obviously there is a way as the profilers are able to do it, but it is certainly not a trivial task.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|