Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2007

Tip: Looking for answers? Try searching our database.

Didn't work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gold Panther - 11 Apr 2007 18:35 GMT
The article seems to be missing something.  I've jerry-rigged some
message boxes into my DLL that fires the event, and I get them every
time.  It seems to say that there are no connections although the
program I have that has the event sink has advised the DLL that it
wants the messages like in the tutorial.  Not sure what is wrong.  My
code it precisely modeled after the tutorial if you want code.  It
looks exactly the same with a couple of variable name changes.  What
could be wrong?
Gold Panther - 11 Apr 2007 18:38 GMT
Sorry, thought I was replying instead of posting new.  The tutorial
can be found at:

http://support.microsoft.com/kb/811645

It's about writing event sinks in C# to catch events from C++/COM.
Gold Panther - 12 Apr 2007 15:06 GMT
Ok.  If I get 405 views in the first 19 hours and there are no
responses, I must've not given enough information.

The idea is that I have an ASP 2.0 page with a C# code file.  I wanted
to reference a DLL, which was written in C++/COM/ATL, whose only
responsibility is to fire an event when told to do so.  The firing of
the event gets all the way to the point of a for loop used to let the
subscribed event sinks know that the event has fired.  The generated
for loops looks like the following:

int CConnections = m_vec.GetSize();
for(IConnections = 0; IConnections < CConnections; IConnetions++)

Upon throwing in some message boxes, I found that CConnections is
equal to zero.  Here's where the event sink comes in:  there's another
program running that references the same DLL and has implemented an
event sink like in the above mentioned tutorial.  It initializes the
event sink and doesn't cause an exception when it advises an object of
the class inside the DLL.  My take from Microsoft is that that means
it is now waiting for the event.  So, now I have a program firing an
event and one sinked to an event...but the event sink isn't catching
the event being fired.

I've tried two other options.  One idea I had was that maybe it was
instantiating different instances of the DLL.  The instances being in
different process spaces may make the catching of the event impossible
since they don't know of each other.  Well, I tried to go back and
make the DLL an executable service.  It works exactly the same way
with the exact same problem.  Ok, well, I thought to try accomplishing
this through delegation like in the second half of the above mentioned
tutorial.  Now, I'm in a whirlwind of confusing documentation trying
to find out how to create an event handler for a custom event.  All I
keep getting are articles on how to create event handlers for events
under the System namespace (i.e. Click, SelectedIndexChanged, etc.)  I
can't figure out if I need to just inherit from IEvent or what within
the service.

Anyway, any help would be greatly appreciated.  To recreate the DLL
(ATL Control) or service (ATL Simple Object), use the tutorial on ATL
Objects at the following link:
http://msdn2.microsoft.com/en-us/library/1byykx68(vs.80,d=printer).aspx
Gold Panther - 24 Apr 2007 18:52 GMT
The initial problem is that the service is missing a class factory.
Since adding the macro DECLARE_CLASS_FACTORY_AUTO_THREAD (which was
the only "DECLARE_CLASS_FACTORY" that mentioned out of process
servers) in ProblemEventSrc.h under
DECLARE_REGISTRY_RESOURCEID(IDR_PROBLEMEVENTSRC), the applications now
fail within atlcom.h with an E_FAIL HRESULT.  A few lines above the
failed assertion there is the comment that the service "cannot
aggregate across apartments."  I thought this might be caused by the
service being set up in the wizard as "Apartment" threading which is
STA instead of "Free" threading.  I changed the first inherited class
template of CProblemEventSrc from
CComObjectRootEx<CComSingleThreadModel> to
CComObjectRootEx<CComMultiThreadModel> to see if I was right.  It
still gave the same error.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.