No, the event isn't a custom event declaration. Here is the code from
the assembly I'm dynamically loading:
--- Begin Code Block ---
namespace PlayEngine
{
public class D3DVideoTask : Task, IVideoTask
{
public D3DVideoTask() : base()
{
}
public override void Run()
{
Application.DoEvents();
}
public void CreateViewport()
{
viewport = new Form();
viewport.Show();
viewport.Closing += new CancelEventHandler(viewport_Closing);
}
protected override void Start()
{
}
protected override void Stop()
{
}
protected override void Suspend()
{
}
protected override void Resume()
{
}
protected void viewport_Closing(object sender, CancelEventArgs
e)
{
if (Closing != null)
{
Closing(this);
}
}
private void InitalizeDirect3D()
{
...
}
public event VideoEventHandler Closing; // <- troublesome event
private Form viewport;
private Device d3dDevice;
}
}
--- End Code Block ---
And here is the line of code used to access the class from this
assembly:
Task task = (Task)Activator.CreateInstance(Assembly.Load("D3DV ideoTask").GetType("PlayEngine.D3DVideoTask",
true));
Note that it appears to be the GetType() method that throws the
exception.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:<Oi**************@TK2MSFTNGP10.phx.gbl>...
Eli,
The only thing that I can think of is that there is a custom event
declaration (using add and remove) instead of the normal event declaration.
Is this assembly one that you have the code for, or is it something you can
not modify? If you have the code for it, then can you post it (if not the
assembly itself) and the code you are trying to use to access it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Eli Block" <eb****@gmail.com> wrote in message
news:76*************************@posting.google.co m... When getting a type from a dynamically loaded assembly using
Assembly.GetType, I receive the following exception:
An unhandled exception of type 'System.TypeLoadException' occurred in
playengine.dll
Additional information: Method add_Closing in type
PlayEngine.D3DVideoTask from assembly D3DVideoTask,
Version=1.0.1632.5152, Culture=neutral, PublicKeyToken=null does not
have an implementation.
I'm not sure where it is getting this 'add_Closing' method from. The
class does have an event called 'Closing'. I tried defining custom add
and remove accessors for the event but that did not make the exception
go away. What is the problem?