Problem with events

dotnet framework

    Next

  • 1. Problems with remoting to a web farm
    The application works fine in single server environment. The application makes remoting calls through the binary formatted http channel to a remote object hosted in IIS (IIS6 on Win2003). The remoting url is protected in web.config for Windows authentication. The new web farm includes 3 nodes balanced by Alteon web switch with no client affinity. The application hangs randomly when making remoting calls using the url with the virtual host name. Any help is greatly appreciated.
  • 2. remoting nested types
    Hi, I have a remoting problem concerning returning a control from a service to a client app... the code is as follow : <code start> dim x as MyControl x = MyDistantObject.GetMyControl() MyForm.Controls.Add(x) <code end> The MyDistantObject is valid. the x object seems to be set when calling the Add method, but the MyForm.Controls.Add(x) line causes an exception saying that : (in french) "Autorisation refus. Impossible d'appeler des methodes non public ou static a distance." (In english, but I translated myself so it could be something else) "Autorisation denied. Impossible to call non public or static methods remotely" Does someone have any idea why it would cause this exception at this line? thanks
  • 3. structure for error handling for calls to a MarshalByRefObject
    hi i'm currently implementing a distributed chat application (yes another one - for university) using MarshalByRefObjects (with RemoteConfiguration.RegisterWellKnownServiceType and Activator.GetObject and stuff around) now i want to (and did) implement a reconnect method that tries to reach any of the available servers and sets this as the one to work on with the subsequent communication. as soon as something goes wrong (a call breaks) i'll reconnect again searching for another server and retry whatever just went wrong. this should look something like: while ((connected)&&(!ok)&&(reconnectTries < maxReconnectTries)) { try { ok = serverobj.dosomething(); } catch { reconnectTries++; reconnect(); } } connected means that the reconnect found another working server. ok means the dosomething was sucessfull the problem i'm facing is that i dont see any alternative to writing this wrapper thing around every single call of a method of the MarshalByRefObject (the dosomething()s). does anybody know some nice pattern or feature of the remoting to have a single point in the code to do the failure treatment? paul
  • 4. Apparent timeout on a long-running remoted process.
    In an application using .NET remoting (the remoted server is hosted in IIS), a long-running remoted call terminates after running for around 46 minutes. There is no exception thrown on the server, nor do the ASP.NET performance counters register any application or worker process restarts. The client end of the remoted call registers a System.Net.WebException: 'The underlying connection was closed: An unexpected error occurred on a receive.' Since there are many long-running requests launched by a client, the machine.config entries (processModel/responseDeadlockInterval) have been configured to keep the request alive for 5 hours. We can see no other obvious timeouts on the server that would cause a request to be terminated. The host platform is IIS6 running on Windows 2003 Server (Enterprise). Are we missing any configuration settings? Are there any performance counters that can be logged or ways to monitor and track down why the request is being terminated? Dolph Priest

Problem with events

Postby UGF1bCBL » Fri, 11 Mar 2005 09:49:02 GMT

I have a MarshalByRef object that contains three private delegates all marked 
on NonSerialized.

When I connect to the remoting server (running in a service under 
LocalSystem) with my client winforms app everything works as it should.

However, if I exit the client app and start it up again, I get " The 
underlying connection was closed: Unable to connect to the remote server." 
when I access any methods that end up raising one of the internal events.

Does anyone have any suggestions?

Thanks!

Paul K

Re: Problem with events

Postby Bob Rundle » Fri, 11 Mar 2005 13:07:11 GMT

Paul,

I think you are leaving a lot out.  It is best if you post some code. 
Natually you will need to simplify a lot before you post...and in many cases 
you will find the problem in doing this.

Your events are not working on 2nd start of client.  You have to wire up the 
events each time the client starts...

Client.Log("Referencing the server ...");
IServer iServer = (IServer) Activator.GetObject(typeof(IServer), 
"tcp://localhost:1000/wb.soap");
Client.Log("Hooking the events ...");
MyEventHandlerDelegate clientHandler = new 
MyEventHandlerDelegate(Client.EventReceiver);
EventWrapper eventWrapper = new EventWrapper(clientHandler);
iServer.MyEvent += new 
MyEventHandlerDelegate(eventWrapper.ServerEventHandler);

I assume you are doing this.  Now chances are your client did not disconnect 
the event before it shutdown.  So there are event handlers in the server 
which will throw exceptions as soon as an event is raised.  So...event if 
add good event handlers behind these, the events will no be called.

The standard event handling mechanism is not good enough for remoting 
events.  You need to have an asynchronous way of firing events such that one 
bad event handler does not disable the rest.

Regards,
Bob Rundle









Re: Problem with events

Postby UGF1bCBL » Fri, 11 Mar 2005 20:55:04 GMT

You are correct in that I was not disconnecting the events before the client 
shut down.

Also, I found some articles regarding the BeginInvoke, EndInvoke and 
GetInvocationList methods on Delegate types, so I think I'm set for getting a 
basic test in place for async events.

Thanks for the information!

Paul K

Similar Threads:

1.Problem with Event sink (ATL C++) when the event source is a C# object

Hello everybody,

I need to send from a C# object events, that have to be caught
in my C++ code. I have followed the instructions from the MSDN article
"Raising Events Handled by a COM Sink", but I have a problem
when I call AtlAdvise in the C++ client: the method FindConnectionPoint
will fail with error CONNECT_E_NOCONNECTION (0x80040200).

So I suppose there is a problem with the connetion point map. I found
in another posting that the event instance name has to be the same as the
interface method, which I did, but with no result.

How can I solve my problem? Stupid ideea: is there any way to define 
(correct)
manually the message map for the C# object, like it was possible in C++?

Many thanks for your help,
Cristian





2..NET event, VC6 sink, problems with event parameters

Hi-

We have some .NET code that generates an event. The 2nd parameter of the
event is a C# class we derived from EventArgs.

A VC6 C++ client is subscribing to the event, we are using the
IDispEventImpl<> template in ATL, and have specified the
ComSourceInterfacesAttribute on our event generating class, as well as the
InterfaceTypeAttribute(InterfaceIsIDispatch) on our dummy interface for the
event in C#.

We are getting the callback made into C++ with no problem. The problem
occurs when we try to call a method of our EventArgs-derived parameter to
the event callback. When we make a call to say,
get_Name(&bstr); on our EventArgs-derived class in the C++ callback ('Name'
is a property in our EventArgs derived class) we get the following error
from the VC6 debugger:

"The value of ESP was not properly saved across a function call. This is
usually the result of calling a function declared with one calling
convention with a function pointer declared with a different calling
convention"

I have tried various settings in Project->Settings->C++->Code
Generation->Calling Convention, with no differences in behavior.

When our test app is in VB6 instead of VC6, we can access the parameters's
methods/properties with no problesm from within the event's callback
function.

Another note, when we implemented this event as a dual interface, and
received it in VC++ via a custom interface (rather than IDispatch), I am
pretty sure we were able to access the parameters methods and properties
with out the above crash. the problem, of course, is that with our COM
interface declared as Dual rather than IDispatch, we were unable to receive
the event in VB6.

Sorry for the long post, but there's no easy way to describe the problem.
Can anybody pinpoint what we are doing wrong so that we can access the event
parameters from C++?

Thanks in advance,
Eric.


3.Problem with Event sink (ATL C++) when the event source is a C# ob

Sorry, I forgot to mention that I am an MSDN subscriber, so I would
be pleased to see some "Microsoft" answers.

Regards,
Cristian Marinescu


"Cristian Marinescu" wrote:

> 
> Hello everybody,
> 
> I need to send from a C# object events, that have to be caught
> in my C++ code. I have followed the instructions from the MSDN article
> "Raising Events Handled by a COM Sink", but I have a problem
> when I call AtlAdvise in the C++ client: the method FindConnectionPoint
> will fail with error CONNECT_E_NOCONNECTION (0x80040200).
> 
> So I suppose there is a problem with the connetion point map. I found
> in another posting that the event instance name has to be the same as the
> interface method, which I did, but with no result.
> 
> How can I solve my problem? Stupid ideea: is there any way to define 
> (correct)
> manually the message map for the C# object, like it was possible in C++?
> 
> Many thanks for your help,
> Cristian
> 
> 
> 
> 
> 
> 

4.Problem assigning event handler to object.event

C# 2.0

I have declared some event arguments like this:

    public class ModeStateChangedEventArgs : EventArgs
    {
            Gen.DataState myState;

            public ModeStateChangedEventArgs() { }

            public ModeStateChangedEventArgs(Gen.DataState val)
            {
                myState = val;
            }

            public Gen.DataState MyState
            {
                get { return myState; }
            }
    }


In a business object I declare the event and use it like this:

Public class BizClass
{

        public event EventHandler<ModeStateChangedEventArgs> 
ModeStateChangedRaised;


        protected virtual void 
OnModeStateChangedRaised(ModeStateChangedEventArgs e)
        {
            try
            {
                EventHandler<ModeStateChangedEventArgs> handler = 
ModeStateChangedRaised;
                if (handler != null)
                {
                    handler(this, e);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.ErrLog(ex);
            }
        }

//And I raise the event like this:

     Void SomeMethod()
     {
            ModeStateChangedEventArgs arg = new 
ModeStateChangedEventArgs(myModeState);
            OnModeStateChangedRaised(arg);
     }
}

Now is a list class I want to create instances of BizClass, assign and event 
handler to them and then add them to the list.


Public class ListOfBizClass : BindingList< BizClass >, IBindingList
{
//This is where I need help...
        public event EventHandler<ModeStateChangedEventArgs> 
ModeStateChangedRaised;


        protected virtual void 
OnModeStateChangedRaised(ModeStateChangedEventArgs e)
        {
            try
            {
                EventHandler<ModeStateChangedEventArgs> handler = 
ModeStateChangedRaised;
                if (handler != null)
                {
                    handler(this, e);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.ErrLog(ex);
            }
        }


        public void GetListFromDatabase()
        {
            base.Clear();
            dsContactMngr ds = oData.PersonGetRecShort();
            foreach (dsContactMngr.tbPersonShortListRow dr in 
ds.tbPersonShortList)
            {
                BizClass obj = new BizClass (dr.ID, dr.FName, dr.LName);
//This is where I get a compile error: 'new 
EventHandler(OnModeStateChangedRaised)'
//Compile error says: 'No overload for 'OnModeStateChangedRaised' matches 
delegate'
                obj.ModeStateChangedRaised += new 
EventHandler(OnModeStateChangedRaised);
                base.Add(obj);
            }
        }
)

Can someone shed explain what I need to do here?

THANKS!
-- 
 XXXX@XXXXX.COM  


5.Problem with Event Log event triggers

Hi,

I have the following code to raise events when something gets written
to the Application log.  The problem I'm seeing is when a bunch of
entries get written to the log at the same time (or within a couple of
seconds of each other).  I receive an event for the first entry, but
the events for the other entries aren't triggered until another entry
is written to the log.

System.Diagnostics.EventLog eventLogToMonitor = new
System.Diagnostics.EventLog();

eventLogsToMonitor.Log = "Application";
eventLogsToMonitor.EnableRaisingEvents = true;
eventLogsToMonitor.EntryWritten += new
System.Diagnostics.EntryWrittenEventHandler(this.entryWrittenToLog);

.....

private void entryWrittenToLog(object sender,
System.Diagnostics.EntryWrittenEventArgs e)
{
	Console.WriteLine(DateTime.Now + ": " + e.Entry.Source);
}


For example,

2:00:00 pm - Error 1 written to log
2:00:00 pm - Error 2 written to log
2:00:01 pm - Error 3 written to log
2:05:00 pm - Information 1 written to log

I see on the console:

2:00:00: Error 1 source
2:05:00: Error 2 source
2:05:00: Error 3 source
2:05:00: Information 1 source

Basically, an event is raised in my code when Error 1 gets written.  NO
events are raised for Error 2 or 3.  Then 5 minutes later when
Information 1 gets written, I see events being raised for Error 2, 3
and Information 1 all together.

Any ideas on what the problem might be?

Thanks,
Amol

6. Problems with Events using Remoting with IPC

7. Problems wit events

8. Problems with Events from Items Collection



Return to dotnet framework

 

Who is online

Users browsing this forum: No registered users and 65 guest