DCSIMG
The exception “The invoked member is not supported in a dynamic assembly” and the Entity framework. - Manu Cohen-Yashar's Blog

Manu Cohen-Yashar's Blog

The exception “The invoked member is not supported in a dynamic assembly” and the Entity framework.

The entity framework is based on mapping files .csdl and ssdl. Those files are actually put in the resource of the assembly where you wrote your EF code.

When invoking the entity framework the connection string has to be parsed. The connection string tells the EF in which assembly resource it will find the mapping files.

Unfortunately the default value in the connection string for that is ‘*’ .
For example: “metadata=res://*/Data.Seating.csdl|res://*/Data.Seating.ssdl|res://*/Data.Seating.msl”

 

The ‘*’ means all assemblies. It is not a surprise that the EF searched all possible assemblies in the app-domain for the resource that includes the mapping files it needs.

This cost performance but the real problem is: “What happens when an assembly cannot present its resources? “
 For example dynamic assemblies (assemblies that are created on run-time using reflection.emit)
 can not present their resources. In that case the exception “
The invoked member is not supported in a dynamic assembly” will be thrown.

 

The solution is simple: Simply replace the ‘*’ with the assembly name that contain the resource.

For example: metadata=res://AssemblyName/Ticketing.csdl|res:// AssemblyName /Ticketing.ssdl|res:// AssemblyName /Ticketing.msl  …”

 

Manu

Comments

Geoff said:

Thank you so much for posting this. I've been googling for half an hour trying to find the cause of the hundreds of exceptions scrolling up my debug output window in the idea.

# March 1, 2009 2:26 AM

nick_oloace said:

# May 18, 2009 9:58 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: