|
According to MSDN forums your app might have configuration problem.
Life is a stage and we are all actors!
|
|
|
|
|
Thank you very much for the reply, apparently as you said, there is a configuration problem. I needed to ADD an App.config to my application. It's empty, but that did the trick.
|
|
|
|
|
Hi,
my app logs correctly while code is beeing executed within my method DoIt . But it doesn't log in the Process.OutputDataReceived 's EventHandler even if p_OutputDataReceived is called.
Is there anything I need to look at while using Process ?
private void DoIt(string arguments)
{
_log.Fatal("TEST");
Process p = new Process();
p.StartInfo.FileName = @"D:\vssTOOLS\NetJobs\UpdateDealArchiveInstrSeq\UpdateCaller\bin\Debug\UpdateDealArchiveInstrSeq.exe";
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
p.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(Caller)).Location);
p.StartInfo.UseShellExecute = false;
p.StartInfo.Arguments = arguments;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
do
{
System.Threading.Thread.Sleep(100);
} while (!p.HasExited);
if (p.ExitCode != 0)
{
for (int i = 0; i < procOut.ToString().Length; i += 2000)
_log.Info(procOut.ToString().Length > i + 2000 ? procOut.ToString().Substring(i, 2000) : procOut.ToString().Substring(i));
for (int i = 0; i < procErr.ToString().Length; i += 2000)
_log.Error(procErr.ToString().Length > i + 2000 ? procErr.ToString().Substring(i, 2000) : procErr.ToString().Substring(i));
throw new ApplicationException("Es ist ein Fehler aufgetreten: " + procErr.ToString());
}
}
StringBuilder procOut = new StringBuilder();
StringBuilder procErr = new StringBuilder();
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
procErr.AppendLine(e.Data);
_log.Error(e.Data);
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
procOut.AppendLine(e.Data);
_log.Info(e.Data);
}
|
|
|
|
|
Hi,
I am using a procedure which selects some rows and handles a output parameter.
I am executing this procedure using SqlDataReader.
Problem Is ,
If Connection is kept open after ExecuteReader(), Sql Reader is working fine and able to do data binding. But, output parameter is returing null value.
If Connection is closed, I am able to get the correct output parameter value. But, SqlDataReader is not working.
Any Ideas to make both working regardless of connection status.
Thanks,
Nagaraj
|
|
|
|
|
You can't. You only get the ouput parameter back when you close the connection. Its always been that way.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Thanks Bob,
My code is fetching the records for GridView Binding (for the selected PageIndex) and total results in single call to database.
I am returing SqlReader from DAC to BusinessLayer and to Code file from there.
Is there any better way to achive this?
Thanks again
Nagaraj
|
|
|
|
|
DataReader needs open connection.
Better you use DataSet, DataAdapter.
|
|
|
|
|
You could use a dataset and fill that, I think you would then get your output parameter straight away - not 100% sure though, I haven't tried it. Alternatively, return 2 recordsets and use a dataadaptor to fill a dataset, you then should get what would have been the output param in its own table.
Hope some of this helps
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Ashfield wrote: think you would then get your output parameter straight away
Unfortunately not - you have to iterate over the lot before you get the output parameter back. This has caused me grief a few times.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: Unfortunately not - you have to iterate over the lot before you get the output parameter back
Ought to have guessed that really.
I never tried it, I generally don't bother with output parameters simply because you can't get them when you really want them, usually first! If I need something like that I often return 2 record sets, the 1st with what would be the output parameter and the 2nd with the real data - probably not ideal, but it works for me
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I have this button that I want disabled from a check box on a separate form. Its an options window and one option is to disable a certain button but the button is on the previous from. How can i disable the button from the form? I cant just start typing because it does not know the button exists. due to it being on another form.
Y*Live Long And Prosper*Y
|
|
|
|
|
Raise an event in the form with the checkbox that the form with the button subscribes to.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
You might want to delete the repost you made above this one before you get flamed for it! I think the CP servers had a bit of a fit a few minutes ago, so probably when you thought it hadn't submitted - it actually had.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
yeah sorry lol I thought it didn't go through
Y*Live Long And Prosper*Y
|
|
|
|
|
You could do it using events or delegates or custom WM messages
|
|
|
|
|
Can someone please be more specific? Im new to programming.
Y*Live Long And Prosper*Y
|
|
|
|
|
Working Example:
using System;
using System.Windows.Forms;
public partial class FormButton : Form
{
public FormButton()
{
InitializeComponent();
}
private void FormButton_Load(object sender, EventArgs e)
{
FormCheckBox formCheckBox = new FormCheckBox();
formCheckBox.CheckStateChanged += formCheckBox_CheckStateChanged;
formCheckBox.Show();
}
void formCheckBox_CheckStateChanged(object sender, CheckStateEventArgs e)
{
button1.Enabled = e.IsChecked;
}
}
using System;
using System.Windows.Forms;
public partial class FormCheckBox : Form
{
public event EventHandler<CheckStateEventArgs> CheckStateChanged;
public FormCheckBox()
{
InitializeComponent();
}
private void checkBox1_CheckStateChanged(object sender, EventArgs e)
{
OnCheckStateChanged(new CheckStateEventArgs(checkBox1.Checked));
}
protected virtual void OnCheckStateChanged(CheckStateEventArgs e)
{
EventHandler<CheckStateEventArgs> eh = CheckStateChanged;
if (eh != null)
eh(this, e);
}
}
public class CheckStateEventArgs : EventArgs
{
public CheckStateEventArgs(bool isChecked)
{
IsChecked = isChecked;
}
public bool IsChecked
{
get;
private set;
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I've already read that DaveyM69 has explained to you how to use events/delegates for solving your problem.But sometimes you need to notify other instances of your app for something important.In this case events and delegates are not useful,because you can't get valid pointers of the forms belonging to another instance of the app.In this case you have to use custom WM messages.To register custom WM message call RegisterWindowMessage native function.
And to send message call SendMessage native function passing HWND_BROADCAST value for hWnd parameter.But this function doesn't seem to work with child windows,but it works with hidden top windows for example.
But be careful with that option-it could damage OS performance.
|
|
|
|
|
I'm not sure how much code you need to see to handle this problem.
I am trying to add the ability for any logged-on client to send a message to all other logged-on clients.
My server code looks like this:
public OedipusServer
{
bool ensureSecurity = true;
RemotingConfiguration.Configure("oedipus.exe.config", ensureSecurity);
UserList insUserList = UserList.Instance;
ObjRef refUserList = RemotingServices.Marshal(insUserList, "UserList");
...
ServerClass insServerClass = ServerClass.Instance;
ObjRef refAServerClass = RemotingServices.Marshal(insServerClass, "Messaging");
}
public class ServerClass : AbstractServer
{
private static ServerClass mInstance = null;
public static ServerClass Instance
{
get
{
if (mInstance == null)
mInstance = new ServerClass();
return mInstance;
}
}
public override Object InitializeLifetimeService()
{
return null;
}
public override void myStatusHasChanged(int userID, int newStatus)
{
FireNewBroadcastedMessageEvent(userID, newStatus);
}
public event StatusChangedEventHandler myStatusChangedHandler;
public override event StatusChangedEventHandler myStatusChangedEvent
{
add
{
myStatusChangedHandler = value;
}
remove
{
}
}
protected void FireNewBroadcastedMessageEvent(int userID, int newStatus)
{
myStatusChangedHandler(userID, newStatus);
}
}
I have another project, Messaging, which looks like this:
public delegate void StatusChangedEventHandler(int userID, int newStatus);
public abstract class AbstractServer : MarshalByRefObject
{
public abstract void myStatusHasChanged(int userID, int newStatus);
public abstract event StatusChangedEventHandler myStatusChangedEvent;
}
public abstract class AbstractBroadcastedMessageEventSink : MarshalByRefObject
{
public void callbackStatusChanged(int userID, int newStatus)
{
internalCallbackStatusChanged(userID, newStatus);
}
protected abstract void internalCallbackStatusChanged(int userID, int newStatus);
}
On the client side I have:
class EventSink : AbstractBroadcastedMessageEventSink
{
protected override void internalCallbackStatusChanged(int userID, int newStatus)
{
}
}
private AbstractServer rmMessaging;
public Office()
{
rmMessaging = (AbstractServer)Activator.GetObject
(typeof(AbstractServer),
System.Configuration.ConfigurationManager.AppSettings
["AbstractServerUrl"]);
EventSink sinkStatusChanged = new EventSink();
rmMessaging.myStatusChangedEvent +=
new StatusChangedEventHandler(sinkStatusChanged.callbackStatusChanged);
}
private void button1_Click(object sender, EventArgs e)
{
rmMessaging.myStatusHasChanged(23, 14);
}
It's subscribing to the event which raises the runtime error "DelegateSerializationHolder is not permitted to be deserialized at this security level".
|
|
|
|
|
It seems your remoting configuration is not correct.This stuff might help you to solve your the problem.
|
|
|
|
|
Thanks. I found another article which discussed the problem and offered the solution of using a wrapper class. It still didn't work until I realised that I couldn't use tcp.
Adding a separate channel using http/Soap/Singleton (as your article states) solved the problem.
So I have a tcp channel for my data-access and an http channel for braodcasting messages.
|
|
|
|
|
At the risk of sparking of hilarious ridicule, can I get a ListView Control which mirrors the content of another?
I have a listview which is populated and another 'blank' (unitilialised) listview which I need to 'mirror' the first.
Any pointers welcomed.
|
|
|
|
|
Well what ever you do with the first one, just do it to the second one at the same time
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hello. This is my problem:
try
{
Application.Run(new Form1());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
In Debug-Mode (F5), if exception is thrown, then it goes to catch block.
In Release-Mode (Ctlr-F5), if exception is thrown, then it shows "unexpected exception" from windows. Catch block is not called.
How can I catch unexpected exception in Release-Mode ?
Thanks.
|
|
|
|
|
There's a special event that gets triggered whenever there's an unhandled exception. Your application could subscribe to the Application.ThreadException [^]-event.
Something like this (adapted from the MSDN-example, not tested);
{
Application.ThreadException += new ThreadExceptionEventHandler(MyErrorHandler);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.Run(new Form1());
}
private static void MyErrorHandler(object sender, ThreadExceptionEventArgs t)
{
ShowMessage(t.ToString());
}
I are Troll
|
|
|
|