System.TypeLoadException problem

  • Thread starter Thread starter Eli Block
  • Start date Start date
E

Eli Block

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?
 
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?
 
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("D3DVideoTask").GetType("PlayEngine.D3DVideoTask",
true));

Note that it appears to be the GetType() method that throws the
exception.

Nicholas Paldino said:
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]
- (e-mail address removed)

Eli Block said:
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?
 
Back
Top