|
Hi Every body.
I have a scenario in which I have to send series of commands to command prompt. I have achieved It almost using system.diagnostics.Process but when I execute my program in windows XP, it does not behave propely as it behaves in Windows 7.
I am trying to open other applications in interactive mode.Honestly I am able to do it in windows 7 but in win XP process are just started and lives in background. as soon as I close the console they begins to launch one by one. There is something missing in my code which is not letting them launch(Problem is Only in XP).
Following are the steps I'm doing in C# code.
Step #1: Opening command prompt
using (Process process = new Process())
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.WorkingDirectory = @"C:\";
process.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, "cmd.exe");
process.StartInfo.RedirectStandardInput = true;
process.OutputDataReceived += ProcessOutputDataHandler;
process.ErrorDataReceived += ProcessErrorDataHandler;
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
}
Step 2: Giving commands one by one by using standard input.
I need you people to correct me if I am going in wrong direction.
Please help me identify the problem that who is blocking programs and why they are launching after closing console
|
|
|
|
|
Why did you wrap each Process in a using block? You're launching processes incorrectly as you're Disposing the Process object right after you create it and start the Begin...Reads!
It's only by chance that this works under Windows 7.
Create your Processes and keep them in a List<process>. Don't use a using block around them.
|
|
|
|
|
Syed Ata-Ur-Rehman wrote: I am trying to open other applications in interactive mode Then it is not necessary at all to start that command with a "cmd.exe ..." call. Just call the application you need, e.g. process.StartInfo.FileName = Winword.exe
|
|
|
|
|
Since that I have created about 15 separate libraries for the main exe, they are in the same folder as exe.
I was thinking of putting those class libraries (DLLs) into a folder called "Libraries" in the main exe folder, so that the directory will look cleaner and organized.
How can I do that so that the exe file can load libraries from "Libraries" folder?
I'm using Visual Studio 2010 Premium.
|
|
|
|
|
To load an assembly from a specified subdirectory of the application's base directory requires a modification to the configuration file.
e.g.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Libraries"/>
</assemblyBinding>
</runtime>
</configuration>
See probing element[^] at msdn.
The Assembly Fusion log viewer[^] will show all paths searched during assembly loading and is a useful tool to have running, especially if you make a mess of editing the config file. It's helped me out more than once!
Alan.
|
|
|
|
|
|
Hello. I'm streaming a webcam using DirectShow. I can open the camera fine on a windows form once. But, If I close the camera and then try to reopen it my code fails on the RenderStream line. Once I restart my application everything is fine again. I'm quite certain I'm freeing everything up, but i'm stumped. Any help would be GREATLY appreciated.
Guid cat = PinCategory.Capture;
Guid med = MediaType.Video;
private IBaseFilter sourceBase;
private IGraphBuilder graph;
private ICaptureGraphBuilder2 capGraph;
private ISampleGrabber sg;
private IMediaControl mc;
private IBaseFilter grabberBase;
private VideoInfoHeader videoInfoHeader;
private const int WM_GRAPHNOTIFY = 0x00008001;
private const int WS_CHILD = 0x40000000;
private const int WS_CLIPCHILDREN = 0x02000000;
private const int WS_CLIPSIBLINGS = 0x04000000;
private int frameWidth = 320;
private int frameHeight = 240;
public bool Start(string SystemID)
{
using (DsDevice camDevice = GetDeviceFromMon(SystemID))
{
if (camDevice != null)
{
object comObj = null;
Guid gbf = typeof(IBaseFilter).GUID;
Guid clsid = Clsid.CaptureGraphBuilder2;
Guid riid = typeof(ICaptureGraphBuilder2).GUID;
AMMediaType media = new AMMediaType();
media.majorType = MediaType.Video;
media.subType = MediaSubType.RGB24;
media.formatType = FormatType.VideoInfo;
camDevice.Mon.BindToObject(null, null, ref gbf, out comObj);
sourceBase = (IBaseFilter)comObj; comObj = null;
comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.FilterGraph));
graph = (IGraphBuilder)comObj; comObj = null;
comObj = DsBugWO.CreateDsInstance(ref clsid, ref riid);
capGraph = (ICaptureGraphBuilder2)comObj; comObj = null;
comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.SampleGrabber));
sg = (ISampleGrabber)comObj; comObj = null;
mc = (IMediaControl)graph;
grabberBase = (IBaseFilter)sg;
capGraph.SetFiltergraph(graph);
graph.AddFilter(sourceBase, "Ds.NET Video Capture Device");
sg.SetMediaType(media);
graph.AddFilter(grabberBase, "Ds.NET Grabber");
if (capGraph.RenderStream(ref cat, ref med, sourceBase, null, grabberBase) >= 0)
{
media = new AMMediaType();
if (sg.GetConnectedMediaType(media) >= 0)
{
if ((media.formatType == FormatType.VideoInfo) && (media.formatPtr != IntPtr.Zero))
{
videoInfoHeader = (VideoInfoHeader)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader));
frameWidth = videoInfoHeader.BmiHeader.Width;
frameHeight = videoInfoHeader.BmiHeader.Height;
Marshal.FreeCoTaskMem(media.formatPtr); media.formatPtr = IntPtr.Zero;
sg.SetBufferSamples(false);
sg.SetOneShot(false);
sg.SetCallback(this, 1);
mc.Run();
}
}
}
}
}
return false;
}
public void Stop()
{
if (mc != null)
{
mc.StopWhenReady();
mc = null;
}
if (sg != null)
{
sg.SetCallback(null, 0);
Marshal.ReleaseComObject(sg); sg = null;
}
if (grabberBase != null)
Marshal.ReleaseComObject(grabberBase); grabberBase = null;
if (capGraph != null)
Marshal.ReleaseComObject(capGraph); capGraph = null;
if (graph != null)
Marshal.ReleaseComObject(graph); graph = null;
if (sourceBase != null)
Marshal.ReleaseComObject(sourceBase); sourceBase = null;
videoInfoHeader = null;
}
|
|
|
|
|
What is the exception that it throws?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Thanks for replying. capGraph.RenderStreamdoesn't throw an exception, but it returns -2147024809
|
|
|
|
|
|
OK. It tells me parameter is incorrect. That's the exception thrown. Which leads to believe the one of my two IBaseFilters isn't being released. But I don't see where or how.
|
|
|
|
|
if (grabberBase != null) Why's that there? It should not be disposed before the ReleaseComObject is called.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I know it's unnecessary -- it's just an old habit. Certainly not what's causing my problem though.
|
|
|
|
|
hello
Can you please send me this source code n C#.net
|
|
|
|
|
|
No, because noone writes drivers in C#.
|
|
|
|
|
Hi there,
I need to determine the view permission group(s) from DFS link objects. I couldn't find any advices at all.
Background: We need a tool for billing our used share space. The code for our cost centers is stored in the associated user group objects shown under Properties -> Advanced -> "Configure View permissions" in DFS Management Console.
Any idea will be welcome, WMI, WinAPI Marshalling - whatever...
Thanks a lot
Roland
|
|
|
|
|
I really don't know where to find fault here. So I published this application and tried to run the setup file. Cannot Start Application message box appears and the following is the error.
Quote: ERROR DETAILS
Following errors were detected during this operation.
* [20/2/2014 2:56:41 PM] System.ArgumentException
- Value does not fall within the expected range.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Internal.Isolation.IStore.LockApplicationPath(UInt32 Flags, IDefinitionAppId ApId, IntPtr& Cookie)
at System.Deployment.Application.ComponentStore.LockApplicationPath(DefinitionAppId definitionAppId)
at System.Deployment.Application.SubscriptionStore.LockApplicationPath(DefinitionAppId definitionAppId)
at System.Deployment.Application.FileDownloader.PatchFiles(SubscriptionState subState)
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
What value does not fall within expected range? I really don't get it and am left quite clueless. I really appreciate it if someone can give me some hints.
|
|
|
|
|
Trouble is, it could be anything: My code will throw ArgumentException errors when one of my routines checks it's parameters and finds it to be invalid - so it could be system code that throws it, or yours.
Start by looking at your setup app, and see if you throw the exception in your code there. otherwise, you are down to adding try-catch blocks to your code in the setup to try and work out where the problem is coming from.
Not a lot we can do to help, I'm afraid.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
It is strange. I tried to publish the backed up project file I had saved elsewhere in a different directory and it can be published successfully without this problem! So I copy the whole project folder to my current working directory, replace the existing one, build and publish .. the problem remains. What is that?
I've set my references to Copy Local True.
I'm sure it is not my codes. I have enough try and catch blocks and there is no error or warnings.
|
|
|
|
|
|
Now currently what is happening is ..
I tried to publish the backed up project file I had saved elsewhere in a different directory and it can be published successfully without this problem! So I copy the whole project folder to my current working directory, replace the existing one, build and publish .. the problem remains. Why is that?
I've set my references to Copy Local True.
Let me check out your links. Thanks!
|
|
|
|
|
hi friends,
If you are the POS developer you'd know that if the customer want to pay using EFT I have to have hardware and banking connection over the wire.
How do I make my POS application accept EFT payments?
Are there 3rd party tools that does it?
Are there any FREE 3rd part tools for it?
I was wondering are those 3rd party components provide an API to their .DLLs so that I could program it?
PS- Im using winApps with C# but I have not used MS POS libraries so far
thanks
|
|
|
|
|
You would need to find a bank transaction processing company in your area THAT YOU TRUST(!!) to handle the payments for you.
NONE of them are free.
|
|
|
|
|
To add to what Dave said: Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.
Only get such code from reputable card transaction service companies - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!
Would I trust a free API? Well, let me put it this way: would you trust me with your bank account details?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|