Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > .NET Framework 1.x
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2006, 10:17 AM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default attach FileWatcher eventhandlers dynamically

I'm trying to attach FileWatcher eventhandlers dynamically to a Windows Service. However the code cracks with the following message:

Exception:
{"Object does not match target type." }

Code:
f = a.GetType("System.IO.FileSystemWatcher", true, true);
fw = Activator.CreateInstance(f);

//set the eventhandler
ei = f.GetEvent("Changed");
ei.AddEventHandler(f, new
 FileSystemEventHandler(FileListener.OnChanged));
ei = fw.GetType().GetEvent("Created");
ei.AddEventHandler(fw, new
 FileSystemEventHandler(FileListener.OnChanged));
ei = fw.GetType().GetEvent("Deleted");
ei.AddEventHandler(fw, new
 FileSystemEventHandler(FileListener.OnChanged));
ei = fw.GetType().GetEvent("Renamed");
ei.AddEventHandler(fw, new
 RenamedEventHandler(FileListener.OnRenamed));

Any suggestions?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i attach my sig? Pukanhez Forum and Wrox.com Feedback 2 February 2nd, 2009 08:27 AM
Hi, how can i attach signature? puzobok Forum and Wrox.com Feedback 1 September 12th, 2008 10:51 AM
Scheduling a Job - Filewatcher carumuga SQL Server 2005 1 July 24th, 2008 11:14 AM
Eventhandlers on nodes rauzer Javascript How-To 1 April 1st, 2007 04:45 AM
Attach Database ! pamyral_279 VS.NET 2002/2003 2 May 17th, 2005 07:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.