Is it possible to get a reference to the instance where the method is being called?
One good thing about using an anonymus method is that it allows you to access locals from the enclosing scope. With a first class delegate you cannot pass in any search parameters to the collection, but with anonymity you can easily use whatever local variables you need from the outer method as your search parameters
Hi Manoj,
Can you please give me an answer or references for Akshay's question? i.e
Server A and Server B are listening to the same queue, will both the servers recieve an event when a messge arrives on the queue. Yes they would. - How can I ask one of the servers to process and the other to stand down...
Thanks
Hi Akshay,
Transactional Receive should solve your problem.
Thanks,
Manoj
Applications should be capable of hosting ASMX without having to rely on the services of IIS.
Interoperations allows import the Kernel DLL functions CreateFileMapping and MapViewOfFile and use them even in C#. However related pointers should be defined inside the unsafe blocks. I've never seen that a pointer, which has been allocated by native Kernel function was
moved - vice versa would be strange.
The only, that must be added are mutexes, in order to control access to the shread memory files.
Of course, it is against ideology of C# and the
direction, but it is the case,when it must be done to solve serios tasks.No one of C# IPC methods does not provide same performance as shared memory for example-when a writer process
writes data and reader process uses it. Generally the "management" ideolgy and super wrapping of C# seems to me like a car with automated transmission for a driver, which can use only automated transmission. Could the tandem participate in a serios rallies?
The ProgressChanged and RunWorkerCompleted Events will not allways be handled on the thread the BackgroundWorker was created on.
This depends on the SynchronizationContext of the thread where the Backgroundworker was created on. For Windows.Forms threads this is true, because the WindowsFormsSynchronization Context actually uses Control.Invoke and Control.BeginInvoke to marshall calls to the coresponding thread.
But from a thread with just has a standard SynchronizationContext, the send and post method of this context do not marshall the call to a specific thread!
Regards
TLS serves storage for physical threads, not logical threads.
You should store the transaction in manner that is logical thread specific:
<ThreadStatic()> _
Private Shared _Transaction As IDbTransaction
I am using the same code and created windows services in my local system but if i run my windows service to receive the message. Access denaid the error message i got.
Can u specify the the format name for the Queue Path. Or any security setting has to be enabled.
Hello MVPs,
I have a problem where opening a word document using Process.Start("filename") throws a Win32Exception as below
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ComponentModel.Win32Exception: Access is denied
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start (String fileName)
I tried using Regmon to track any registry access denied, but could not find any problem,
or may be there is some other error i should be looking for.
This error occurs only on specific machines (laptops) and works well for other machines.
Any help on this topic is highly appreciated :)
Jay
Have you sample code ??
i m facing the same problem..my process is not running any application in windows service and run under normal applicatin..can u tell me the solution please..i need it urgent
In a response to Ken, and also to fix the issue, I would like to know why I have to tick and untick the Interact checkbox to make it work. (The code does make it ticked but as no effect).
I've also noticed other ControlSet in the registry,
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MYSERVICE
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\MYSERVICE
Should I change the value for these also.
Why do I need to go under services and untick, tick again, apply to make it work ???
floyd us 27 a t hotmail d o t com
Thanks.
It's a really nice explanation to the point. Thnks in advance
VIRAJ
I worte a Q listener as a window service, it is working for read the local transactional Q. But when I cluster the MSMQ, the Q listenser service can not read the Q any more.
any idea why?
winservice starts the process (Application) but does not bring it to interface. i ve checked Interact with desktop
but doesn't work
using win-XP
VS-2003
I have a problem with windows service. When i run Process.Start("iexplore.exe"), i cant open a iexplore window but the i see the process running in task manager. This services running under windows server 2003, and have checked Interact with Desktop, but doesnt work. My email is roberto@t2o.es . If someone can help me, send me a email please. Thank you for you colaboration.
SNIP is not always the best way to protect your code.
Check out this article
blogs.msdn.com/.../196590.aspx
Roiy
//Quote//
//End Quote
You have to go thru "Manage Computer" and find the Queue. And give permissions ON THE QUEUE...to the "SYSTEM" account (the SYSTEM account local to that computer).
You don't have to do "Full Control", but Send/Receive are necessary. I usually give Get/Set Permissions as well.
Hi,
I have the ollowing code running for runing a console application:
Process myProcess = new Process();
ProcessStartInfo info = new ProcessStartInfo(appName);
myProcess.StartInfo = info;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.Start();
myProcess.WaitForExit();
Here I am passing the names of different console applications in the ProcessStartInfo.
My Problem is that the console application starts, but within a second closes, though when I run this application as a standalone, it runs properly.
Please Help somebody
Nice to read that.. I was confused about mybase and myclass.
Dear,
I have a batch file that runs Adobe.exe application. Executing this batch file from a Windows Application worked fine and the output of the Batch successfully achieved whereas the same code called from an ASP.NET application doesn’t work. The exe is displayed in the Task Manager but doesn’t execute the code it should and the user runing this service is the Administrator.
Apparently it is a security issue sine the problem occurs when hosting the application in IIS but I have tried working with all the permissions and it didn’t work. The Identity of the pool of the web site is Configurable with the System Administrator Credentials.
Many have the same problem but none has listed the solution. This is very urgent, so pleaseeeeeeeeeeeee help :(
Thank you,
Zeina
You could just use string concatenation you just have to be careful to escape any possible attacks.
string.Format("SELECT * FROM table WHERE field='{0}'", userInput.Replace("'", "''"))
I'm sure there are better methods then the Replace in .NET but that would be perfectly save.
This article's attitude is indicative of the overall contempt that C/C++/C# developers had for VB6, even though it filled a need for quick business application development. (where requirements change constantly... hello, real world)
Thus, we ended up with lack of path from VB6 to VB.NET, all because a bunch of eggheads at Microsoft thought they new better than the marketplace!
E.g. Optional parameters
Ok, its somehow better that I write a dozen overloaded methods when a single method with Optional parameters would've done... VB.NET creates the overloads behind the scenes for you.
Why do you C# guys like writing so much code? I can't figure it out?
[assembly:InternalsVisibleToAttribute("MyFriendAssembly, PublicKeyToken=45cb56a45e0a69a1")]
You cannot use PublicKeyToken with a signed assembly
you need to use public key.
Keith
Does any one know a way in which the new process just created can be debugged (in Visual studio) ?
Pingback from Threading in .Net 2.0
Hello,
i'm trying to do something like this, and i want to acces to the argument's instance of the invoked method.
I can access to the metadata (Type, Name) but i can't access to the value when the method is invoked.
How to do this ?
(Sorry for langage i'm not english :P)
>>But from a thread with just has a standard
>>SynchronizationContext, the send and post method of
>>this context do not marshall the call to a specific
>>thread!
Does a standard SynchronizationContext enable the ability to marshall to the original thread?
All of my test code says no, If I output Thread.GetHashCode() and write test code I can see when using ctx.Post, it always uses the running thread ID and not the one I want to marshal to.
I have a question or need to get some thing confirmed because I'm a bit unsure about this.
Looking at Lance Hunts guideline paragraph 4.4 the example says
// Bad!
catch(Exception ex)
{
Log(ex);
throw ex;
}
// Good!
catch(Exception)
throw;
As I understand it is not possible to do as in the good example, since ex is not declared. Or am I wrong?
If I do the good example as you do it, it seems that I get the same result. I'm I right about that?
// Good! (Modified)
2 points.
1. watch out for {0) which looks a lot like {0} which if you're typing fast can happen quite frequently...will result in a very strange message you could end up surfing around for hours trying to find what's wrong...not that that's happened to me or anything.
2. as far as sql injection we do something like this:
String.Format("sql goes here where id = {0}", SqlTool.StringToSQL(m_String));
and have a separate class that handles the '' stuff... this allows you to escape things neatly behind the scenes, still use string.format, and keep code consistent, and still use intellisense to make things speedy...
FindAll allocate, populate and return a new List, plus the syntax is quite unclear.
foreach( Account account in GetAllAccounts() ) {
if( account.Balance == 0 ) {
SendMail( account, "Be aware, you now have a zero balance" );
Done.
Thanks for support
nice work.......
nice explanation with good examples..
Same probleme... It's impossible to start a program when i user windows service. ( Even if i check interract with destok)
very helpful post - used this info to get powershell commands to run from a C# app!!