Problem with events

dotnet framework

    Sponsored Links

    Next

  • 1. Binary serialization of datasets doesn't work
    Hi. I have an application that uses V2 framework. A Windows form application calls a COM+ component function using HTTP remoting (binary channel). ie: ChannelServices.RegisterChannel(New HttpChannel(Nothing, New BinaryClientFormatterSinkProvider, Nothing), False) The COM+ function queries a database and returns a dataset with its RemotingFormat property set to binary ie: ds.RemotingFormat = SerializationFormat.Binary. When the front-end receives the dataset and I check the RemotingFormat it indicates XML!!! Does binary dataset serialization work over HTTP remoting? Is this a bug? Thanks, Mark
  • 2. Remoting security with IIS and custom Forms authentication
    Hi! What are the options for securing remote objects, which are accessible through IIS, when you have an application deployed on the same server, which uses custom Forms authentication? Scenario: Server hosts app a, which is configured as: authentication:Forms, authorization: deny users="?". Now, for Remoting to work, I had to specify that the remoting URI (RemotableObject.rem) requires no authorization, so IIS let the request through. Since this object return reference to another object, IIS (ASP.NET) creates a temporary link to this remote object, which of course can not be known in advance and the request thus fails. The URI is, for instance like this: /ff1338e5_a46f_4577_af4c_726910d1a39f/9AqnyvYRtRnG8Ai_7Q+5KSYG_80.rem Two questions: 1) how to configure IIS (ASP.NET application) to let the remoting requests through 2) how to configure IIS (and remoting app) to be secure? (once the requests will go through). I guess that one can not mix windows authentication for remoting and custom forms authentication for "regular asp.net" application. And the two (asp.net app & remoting objects) have to be deployed within the same application, since remoting object is used to expose some of the asp.net application functionality. Pointers appreciated. Rgds, Miha
  • 3. TransparentProxy casting
    Could some one please tell me how I can cast/determine the compatible interfaces from a TransparentProxy reference, e.g. //using simple interface, defined as: //interface MyService //{ //void MyMethod(); //} IMyService myService = (IMyService)Activator.GetObject( typeof(IMyService), "tcp://localhost:8085/IMyService"); object o = myService; Given an object reference, how can I determine the compatible interfaces, since the as/is operators always succeed regardless, e.g. IEnumerator enumerator = myService as IEnumerator; works. The server type is registered as a a WellKnownServiceType, single call. Thanks for any help

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 83 guest