|
What's BCL? Anyway, I got it. I just used C#/.NET framework, instead of WIN32 API OpenProcess then TerminateProcess. Here's the code:
try
{
System.Diagnostics.Process process = System.Diagnostics.Process.GetProcessById(nProcessID);
process.CloseMainWindow();
process.Close();
}
catch(Exception err)
{
throw new ApplicationException("Exception from CWin32ProcessUtil.KillProcess. ProcessID: " + nProcessID + " Info: " + err.Message);
}
I launched the process using WIN32 API coz I wanted to avoid "TypeInitializationException" when I tried to launch a GUI app from a Windows Service. Thanks though.
norm
|
|
|
|
|
norm wrote:
What's BCL?
Stands for Base Class Library.
-Nick Parker
|
|
|
|
|
I was hoping I could get away with "TypeInitializationException" via Win32 CreateProcess while launching a GUI app from OnStart (Windows Service)
I guess I was wrong.
norm
|
|
|
|
|
Hi ,
i have a winforms control that when i connect it to a datasource generates lots of different objects (all inheriting from component)
what i want is to add those components to the designer surface so that the controls can be accessed on the forms designer/propbrowser
so HOW do i make my control add the generated components to the designer host?
----
scenario:
i add the control to a form
i set a datasource to it
after the source is set , i want lots of dynamicly generated components to appear in the 'component pane' under the form.
//Roger
|
|
|
|
|
At run-time it is easy enough.
But I believe you want to do this at design-time?
If so, it sounds like you want to build a "plug-in." Kind of like the Add New Form wizards.
When you create a plug-in, it exposes the DTE object from which you can work with objects such as Solution, Project, etc.
Hopfully this provides a solution for your needs
|
|
|
|
|
i solved it..
i added a designer to my control and made the designer listen to events from the control
so when the control creates the dynamic components , the designer intercepts them and add them to the designer host..
//Roger
|
|
|
|
|
Is it true that all serviced component must be registered in COM+ catalog? According to the book I'm reading right now, the answer is no. Any class derived from ServicedComponent is a COM+ component - the resulting class library dll is the COM+ application. The dll doesn't has to be installed in GAC or get registered in COM+ Catalog.
To use .NET assembly from COM client, you need to create CCW and use regasm.exe to have it registered in the registry. But, this allows your assembly to be consumed by COM/unmanaged client. You still can't use COM+ attributes or configure the compoent using "COM+ Administration Tools (MMC snap-in) - therefore, a COM+ component is MORE than just a .NET assembly wrapped in CCW.
A COM+ component must:
1. derive from ServicedComponent
2. register in COM+ Catalog, using regsvcs.exe (Which install dll into GAC - meaning you need to first assign a key file)
Your component is then a COM+ serviced component, meaning:
1. you can apply COM+ attributes (like object pooling or JIT..etc)
2. Configure the component using COM+ Administration Tool (MMC snap in).
Is my understanding correct?
norm
|
|
|
|
|
I have an application that consists of a lot of concurrently executing controllers that performs many different time consuming or timed operations. To get an idea what this means practically, you can imagine 10000 threads (each controller), where each thread performs the timed operations by the use of calls/callbacks.
I want to move to some other paradigm. I want a way of simulating several threads (microthreads) and a way of writing C# code that not gets messy by a lot of callback handling.
What I have at the moment is this, for each operation the controller should perform:
void DoOperationX()
{
// Do some stuff or initiate something
}
void OperationXDoneCallBack()
{
// Stuff is done, move to next operation:
DoOperationX+1();
}
What I would like to write code-wise, is the following for each controller. And I would like to simulate concurrent execution of all controllers, only using one real thread (or a few real threads):
void PerformOperations()
{
DoOperation1(); // Perform operation 1, and wait until its done
DoOperation2(); // Perform operation 2, and wait until its done
DoOperation3(); // Perform operation 3, and wait until its done
}
1. How do I simulate microthreads? I can live with the need of calling a special method once in a while to check if the microthread should be paused and execution should be given to the next microthread. Is there a way to copy the current stack and restore it later?
2. Callback hiding. If I can get the microthreading to work, I can hide the callbacks from the API like this:
void DoOperationX()
{
DoTheOperation();
while (!callBackXDone)
{
CheckMicroThread(); // Switch microthread if needed.
}
}
void OperationXCallBack()
{
callBackXDone = true;
}
Am I following the wrong path here? Is there already a simple solution to this?
Regards, Björn
|
|
|
|
|
System.Threading.ThreadPool.QueueUserWorkItem()
-Blake
|
|
|
|
|
Fibers;
<ahref="">http://msdn.microsoft.com/msdnmag/issues/03/09/CoroutinesinNET/default.aspx
Thank You
Bo Hunter
|
|
|
|
|
Really interesting, thanks!
/Björn
|
|
|
|
|
Hi, I'm trying to expose COM+ component via remoting, it works just fine - it seems. But I'm confused by how COM+/Remoting works together.
Remoting - lifetime depends on whether the object is published as SAO(singleton/singlecall), CAO and lifetime services.
In COM+, lifetime of server objects (COM+ application/component) depends on object pooling and whether JIT is enabled. My understanding is that if a COM+ app is published via remoting, than activation option must be "server". I am a little confused at how/what determines an object's life time in this situation. For instance, how can you have a SAO/Singlecall and have object pooling at the same time?
Following are nine possible scenario:
COM+ JIT enabled/Pooling disabled + CAO
COM+ JIT enabled/Pooling enabled + CAO
COM+ JIT disabled/Pooling disabled + CAO
COM+ JIT enabled/Pooling disabled + SAO/Singlecall
COM+ JIT enabled/Pooling enabled + SAO/Singlecall
COM+ JIT disabled/Pooling disabled + SAO/Singlecall
COM+ JIT enabled/Pooling disabled + SAO/Singleton
COM+ JIT enabled/Pooling enabled + SAO/Singleton
COM+ JIT disabled/Pooling disabled + SAO/Singleton
Any idea? Thanks!
norm
|
|
|
|
|
Does anybody know what I'm doing wrong here? I'm trying to encrypt my class before I serialize it. It seems to encrypt and serialize my class just fine (or at least it managles it into something unreadable!), but when I attempt to deserialize I keep getting either SerializationException "End of Stream encountered before parsing was completed", but it seems to work fine without the encryption. I think it has something to do with the way it handles blocks of data, but I'm not sure how to make it work right.
Thanks
<br />
public void SaveClass()<br />
{<br />
IFormatter BinFmt = new BinaryFormatter();<br />
UnicodeEncoding UE = new UnicodeEncoding();<br />
byte[] key = UE.GetBytes(strUser);<br />
<br />
Stream sout = File.Open("Class.bin",FileMode.Create);<br />
RijndaelManaged myRijndael = new RijndaelManaged();<br />
CryptoStream CptOut = new CryptoStream(sout,myRijndael.CreateEncryptor(key,key),CryptoStreamMode.Write);<br />
BinFmt.Serialize(CptOut,this);<br />
sout.Close();<br />
}<br />
<br />
public static MyClass LoadClass()<br />
{<br />
MyClass newObj = new MyClass();<br />
IFormatter BinFmt = new BinaryFormatter();<br />
UnicodeEncoding UE = new UnicodeEncoding();<br />
string currUser = newObj.strUser;<br />
byte[] key = UE.GetBytes(currUser);<br />
<br />
Stream sin = File.Open("Class.bin",FileMode.Open);<br />
RijndaelManaged myRijndael = new RijndaelManaged();<br />
CryptoStream Cptin = new CryptoStream(sin,myRijndael.CreateDecryptor(key,key),CryptoStreamMode.Read);<br />
newObj = BinFmt.Deserialize(Cptin) as MyClass;<br />
sin.Close();<br />
return newObj;<br />
}<br />
|
|
|
|
|
I want to get into threading...
Does anybody know any good C# threading books?
/\ |_ E X E GG
|
|
|
|
|
Tom Archer's Inside C# 2nd Edition contains a whole chapter on Threading. It's very in depth and a great resource for anything C# related.
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
eggie5 wrote:
Does anybody know any good C# threading books?
Just another book to look into: C# Threading Handbook[^]
|
|
|
|
|
My application communicates with a remote object, and the interface for that remote object allows client's to register events with the server. One of the registered events is designed to open a new form on the client, and that new form (subclass of Form, not surprisingly) is instantiated and Show()n by the event code itself. The window that's created appears, but it doesn't display properly. Do such windows (created by Events triggered by a remote object) need to be manually placed in the Application thread so they properly update and respond to user key and mouse click events?
Thanks in advance for any help.
Jerry
jerry@cs.stanford.edu
|
|
|
|
|
I am supposed to develop a three tier client server based model application using replicated databases. this is for a class project. I know how to develop an application that will access a database and perform updates and all that using ADO.
My plan is to structure the tiers in the following manner
1->C# windows application that uses data from the data source
2->Middle ware in charge of connecting to the database and performing transactions based on client requests (replication should also take place here)
3->Actual database. Could just be a simple access database.
My confusion is how to separate the windows application from the middleware. I am used to just using datasets et al (ADO) in my application when connecting to the the database. Also how do I go about replicating the database via the middle ware. I am assuming the middleware would handle all client requests. Aslo, how do I connect to any available database through the middleware since that would be the whole point of replicating the database.
I would also like to be able to "plug-in" a database to the middleware and have it brought up to date to the state of the other replicated databases.
One idea I was thinking about was having a separate dataset for each client.
Thanks in advance
|
|
|
|
|
I have a serializable object which contains some events. I do not want the events serialized because they are oftne watched by non-serializable classes. When I try an add Nonserializable() to the events I get a compile error saying that attribute can be added to fields only. How can I avoid seralizing those events?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
The C# compiler is tricking u a bit here:
events get expanded to:
private event
public event {add; remove;}
Thus setup your events as shown above and place the NonSerializable attribute on the private field
HTH
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Ah. Thanks for the Info.
I had another solution to the problem in the intermin. I created an inner class to house the events and the event raising functions. I then exposed the events through properties (as you've shown above). Then I marked the member variable of the class that held the events as nonserializable()
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
Hi, I'm writing a Windows Service that launches a Windows App on startup. So, what I did was, in OnStart( ):
System.Diagnostics.Process process = System.Diagnostics.Process.Start("C:\\Program Files\\Testing\\ThisWinApp.exe");
I successfully installed the service using InstallUtil.exe. When I "start" the service, I keep getting "TypeInitializationException". Account used in ServiceProcessInstaller is "LocalSystem" - does it has permission to run executable and run exe in "Program Files" folder? I can't configure these rights on my XP machine.
Reference: http://www.dotnet247.com/247reference/msgs/30/150246.aspx
Anyway, I used caspol.exe to check permission on the assembly. Intersecting permission from across "level", the assembly (the Windows Service) got "Fulltrust". So, if it's got to do with security, it must be user role launching/starting the service.
Now, if it's not security, perhaps it's got to do with the fact that any class derived from ServicedBase can't launch anything that has a GUI?
Thanks in advance.
norm
|
|
|
|
|
I am familiar with symmetric and asymmetric algorithms. But I know a little about generating public and private keys in asymmetric algorithms, And this is my question:
Is it possible to generate a public key based on a private key? It's very important for me to do that.
Thanks in advance.
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Not really, but it's more a matter of semantics, you generate a key pair. The private key that is stored at keygen time is really more the 'whole key', with the public key being a subset of the information.
With what tool did you generate the private key for which you want a public key?
--
-Blake (com/bcdev/blake)
|
|
|
|
|
You know, I actully want to use the user's password as a private key on the browser. So if the user changes his password, I want to regenerate a public key on the server for the new private key. My idea is just replacing SSL with a new approach(I am somehow sure that it is possible).
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|