|
Have you looked at the System.Diagnostic.Process class? It has some methods on it to redirect standard output.
|
|
|
|
|
I believe System.Diagnostic.Process only lets you redirect the STDOUT of a child process. His parent process (C#) is running unmanaged code that writes to the console but not via Console.Out.
|
|
|
|
|
You are right on this. With System.Diagnostic.Process you can only read StandardError and StandardOutput and write to StandardInput of the child process, which System.Diagnostic.Process has started.
|
|
|
|
|
If you use C++/CLI, you could write wrapper code. I did not write wrapper code below. However, it is just a demo on how you can integrate manage and unmanage code in C++/CLI
#pragma unmanaged
#include <iostream>
#include <sstream>
#include <string>
class Foo
{
public:
Foo()
{
std::wcout.rdbuf(ostr.rdbuf());
}
void UnmanagedOut()
{
std::wcout << L"George";
}
std::wstring Redirect()
{
return ostr.str().c_str();
}
private:
std::wostringstream ostr;
};
#pragma managed
using namespace System;
int main(array<System::String ^> ^args)
{
Foo foo;
foo.UnmanagedOut();
String ^out = gcnew String(foo.Redirect().c_str());
Console::WriteLine(out);
return 0;
}
|
|
|
|
|
This looks like a nice idea, but this approach will only redirect cout or wcout stream of C++ into a string. But probably anything written via printf to STDOUT and STDERR won't be intercepted.
Another point could be that the unmanged code resides within a DLL, so using this approach won't probably help anyway, because the cout stream is already linked to the underlying API calls. And changing the DLL is a no-go. That makes the problem so difficult.
|
|
|
|
|
Yes, I haven't verified that this will work and I know that it won't capture printf output. However, if you can get this to work then cerr STDERR and printf STDOUT/STDERR would be easy to redirect via a C++ wrapper.
The C++/CLI wrapper assembly will be compiled and linked using your 3rd party unmanage library. Thus, it should have direct access to unmanaged STDOUT/STDERR for redirection. So, instead of get the managed code to redirect, you let the unmnanaged code in the wrapper do the redirecting. Nevertheless, I don't have experience of this working. Also, I heard mention of redirecting STDOUT/STDERR to a pipe in my Google Searches.
Also, I found this code (I don't know how useful it is) doing a Google search:
http://www.123aspx.com/rotor/RotorSrc.aspx?rot=40353[^]
|
|
|
|
|
I just want to confirm that I did get the cout STDOUT to redirect to a string buffer. I created a DLL that outputs to the console via wcout. Then, I created a C++/CLI wrapper of that code in a managed assembly. I referenced the C++/CLI managed assembly in a C# application which received the redirected output into a System.String object.
|
|
|
|
|
I am populating a gridview table with an asp:SqlDataSource and get the data in my codebehind this way:
int ID = (int)ListEmps.SelectedDataKey.Values["EmpID"];
int UnitNum = (int)ListEmps.SelectedDataKey.Values["UnitNum"];
string Unit = ListEmps.SelectedDataKey.Values["UnitType"].ToString();
string FName = ListEmps.SelectedRow.Cells[3].Text;
string LName = ListEmps.SelectedRow.Cells[4].Text;
And I know it retrieves the data properly. I need that data to be used in another .aspx/.aspx.cs file to define some asp:labels. I understand how to do this with SQL using Request.QueryString[], but I'm not sure how to do it with the GridView.
Thanks!!
K. Garl
Intranet Web Coordinator
|
|
|
|
|
kgarl wrote: I understand how to do this with SQL using Request.QueryString[]
and how do you use a QueryString in SQL?
You need to use the same data on two or more forms? Get it from the same source, such as a business or data layer object.
only two letters away from being an asset
|
|
|
|
|
Nevermind. I figured out how to do it last night. Thanks.
K. Garl
|
|
|
|
|
I am wondering about MS Power Point. How does power point keep track of all its slides on the left side, where does it stores all the slides. Does it rewrite everything again on the left side slide when we open a power point file. Can some body tell me in details. Thanks
|
|
|
|
|
netJP12L wrote: where does it stores all the slides
RAM
netJP12L wrote: Does it rewrite everything again on the left side slide when we open a power point file.
Well, when you open a file, it has new files in memory, yes.
netJP12L wrote: Can some body tell me in details. Thanks
I doubt that any of the powerpoint team are in right now. What are you asking for ? do you want to write something similar in C# ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian Graus wrote: I doubt that any of the powerpoint team are in right now.
Did they call in sick?
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
Christian Graus wrote: I doubt that any of the powerpoint team are in right now
That should be on their answering machine
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi
i want to write Client/Server Programming database with vc#2005 & sql2005 or 2000, but how to connect to sqlserver from network and how to insert,Update,Delete transaction in my database on the network??
Please get me an article or full description on this topic.
thanks..
|
|
|
|
|
hdv212 wrote: i want to write Client/Server Programming database with vc#2005 & sql2005 or 2000, but how to connect to sqlserver from network and how to insert,Update,Delete transaction in my database on the network??
Please get me an article or full description on this topic.
Again, your question is pretty vague.
You can use the SqlConnnection class and related objects to connect to an SQLServer via the network. The connection string determines which server to connect to. This[^] covers the standard ways of connecting to the various server configurations.
As for the Insert/Update/Delete, I use stored-procedures that are executed from SqlCommand objects.
The Microsoft Enterprise Library Data Application block[^] is my preferred method of writing DB code.
|
|
|
|
|
Add the server to Visual Studio's server list, and drag and drop.
|
|
|
|
|
hi
does anyone say to me How to acess Sql Server 2005 Reporting Services's Fields and how to get/set it's Values ?
i went many ways for this work but i don't get true results.
Please write a code that i can access to reporting srvice and get/set its values.
thanks
|
|
|
|
|
hdv212 wrote: does anyone say to me How to acess Sql Server 2005 Reporting Services's Fields and how to get/set it's Values ?
i went many ways for this work but i don't get true results.
Please write a code that i can access to reporting srvice and get/set its values.
Your question is a little vague.
Reporting services is usually programmed via it's web-service.
See here[^] for more details, including examples.
|
|
|
|
|
my question:
i read the book of " Schaum’s outline series , THEORY AND PROBLEMS OF DATA STRUCTURES" BY SEYMOUR LIPSCHUTZ.
it is a cool book but in it’s programming problems he want program like in ch5
can any one help tell me if i can make it by c#
or how can i find the answers of this problems
thanks lot
answer:
amirafouad21 wrote:
he want program like in ch5
This makes no sense.
amirafouad21 wrote:
can any one help tell me if i can make it by c#
You can do pretty much any programming problem in C#.
amirafouad21 wrote:
how can i find the answers of this problems
Sounds like you are asking for homework answers. This is a no-no. Also, please title your posts more appropriately rather than just using 'help.'
____________________________________________________
If at first you don't succeed, skydiving might not be for you.
is there any one can help, because i born any one said homework is there any one have a good answer for me not a homework
|
|
|
|
|
You must be specific about your problem. Don't assume that everyone has that book and they will turn the page to chapter 5 and go through the entire chapter to find out which problem you are talking about.
Also I've noticed your previous thread, and honestly I have no idea why did you copy-paste the response to your previous thread? You could have just stated that this is not a homework!!
Bottom line:
1- As you are new to the forums -from your profile-: Welcome to CodeProject.
2- Before posting again in the forums please review these posting guidlines[^]. And I specially mean the be specific part of the guidlines.
3- If you are still stuck in your problem, post exactly what you are stuck in, and we will happily lend a hand if we could.
Regards
|
|
|
|
|
Thanks Nader Elshehabi very much for your reply , but i try to be specific in my question .
the question in liked list in data structure, the problem is that i want an algorithm or code in c# for this case that say write a program which reads an integer K and prints the list of clients of lawyer K and test the program for each K.
i know there is a pointer in c# but how i can make it.
very thx Nader Elshehabi and i hope u can help me
thanks
|
|
|
|
|
First of all; You are always welcome.
Now to your issue:
The summary of your problem is that you want to implement a linked list data structure in C#. Right? Whatever is stored in that linked list -in my following example I will make a sample lawyer object to demonstrate linked lists in C#-, you don't need to use pointer. Yes you can use pointers in C#, but you absolutely don't need them.
I'd like to remind you that objects -ie. instances of classes- are reference type. That means -assuming you made a class named lawyer-:
Lawyer A = new Lawyer();
Lawyer B = A;
Here A, and B are the same lawyer. If you change anything in A it will also change in B and vice versa. So to implement linked lists in C# -using references to objects instead of pointers-, here is a samll sample:
namespace MyNameSpace
{
class Lawyer
{
public string Name;
public string Address;
public string Telephone;
public Lawyer Previous;
public Lawyer()
{
}
}
}
You can now use your Linked list as a stack -First In Last Out-, or a queue -by adding another reference to the Next item-. I believe you made some reading in Data structure and you can get going from here. Here is a small sample of using the above very simple linked list:
Lawyer LastItem = new Lawyer();
for(int I = 0; I <10; I++)
{
Lawyer another = new Lawyer();
another.Previous = LastItem;
LastItem = another;
}
If you still need clarification about anything, just post.
Regards
|
|
|
|
|
very very very thanks Nader relay very thanks,
I am sorry, did u mean i can make like this code, i am sorry again for asking
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Lawyer
{
public string Name;
public string Address;
public string Telephone;
public Lawyer Previous;
public Lawyer()
{
}
}
class Program
{
static void Main(string[] args)
{
Lawyer LastItem = new Lawyer();
for (int I = 0; I < 10; I++)
{
Lawyer another = new Lawyer();
another.Previous = LastItem;
LastItem = another;
}
Console.WriteLine();
}
}
}
-- modified at 12:11 Tuesday 28th November, 2006
|
|
|
|
|
Well, eventually yes. This was just a small test of adding 10 items consecutively to the linked list using a loop. You can use it largely as a stack -I assume you know the difference between a stack and a queue-. In real life you'd be using more complex linked lists -if wou'd use them at all-.
If you get errors or have trouble again, don't hesitate to post.
Regards
|
|
|
|