Exception in constructor of object contextI setup an object context, but when I instantiate it, I get an execption.<br><br>Here is when the error occurs (in auto-generated code):<br><font color="#0000ff" size=2><font color="#0000ff" size=2> <p>public</font></font><font size=2> MySilverEntities(</font><font color="#0000ff" size=2><font color="#0000ff" size=2>string</font></font><font size=2> connectionString) : </p> <p></font><font color="#0000ff" size=2><font color="#0000ff" size=2>base</font></font><font size=2>(connectionString, </font><font color="#a31515" size=2><font color="#a31515" size=2>&quot;MySilverEntities&quot;</font></font><font size=2>)</p> <p>{</p> <p></font><font color="#0000ff" size=2><font color="#0000ff" size=2>this</font></font><font size=2>.OnContextCreated();</p> <p>}<br>Here is the exception<br>System.NotSupportedException occurred<br>  Message=&quot;The invoked member is not supported in a dynamic assembly.&quot;<br>  Source=&quot;mscorlib&quot;<br>  StackTrace:<br>       at System.Reflection.Emit.AssemblyBuilder.GetManifestResourceNames()<br>  InnerException: <br>However, after the excpetion normal execute occurs, meaning that the exception is caught in the base class.<br><br>Any suggestions?<br><br>Thank you<br><br>Sergey.</p></font><hr class="sig">Sergey© 2009 Microsoft Corporation. All rights reserved.Tue, 07 Jul 2009 07:02:11 Zb8847ef1-be17-404a-b35f-4b693ca23c58http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#b8847ef1-be17-404a-b35f-4b693ca23c58http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#b8847ef1-be17-404a-b35f-4b693ca23c58Sergey Barskiyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Sergey%20BarskiyException in constructor of object contextI setup an object context, but when I instantiate it, I get an execption.<br><br>Here is when the error occurs (in auto-generated code):<br><font color="#0000ff" size=2><font color="#0000ff" size=2> <p>public</font></font><font size=2> MySilverEntities(</font><font color="#0000ff" size=2><font color="#0000ff" size=2>string</font></font><font size=2> connectionString) : </p> <p></font><font color="#0000ff" size=2><font color="#0000ff" size=2>base</font></font><font size=2>(connectionString, </font><font color="#a31515" size=2><font color="#a31515" size=2>&quot;MySilverEntities&quot;</font></font><font size=2>)</p> <p>{</p> <p></font><font color="#0000ff" size=2><font color="#0000ff" size=2>this</font></font><font size=2>.OnContextCreated();</p> <p>}<br>Here is the exception<br>System.NotSupportedException occurred<br>  Message=&quot;The invoked member is not supported in a dynamic assembly.&quot;<br>  Source=&quot;mscorlib&quot;<br>  StackTrace:<br>       at System.Reflection.Emit.AssemblyBuilder.GetManifestResourceNames()<br>  InnerException: <br>However, after the excpetion normal execute occurs, meaning that the exception is caught in the base class.<br><br>Any suggestions?<br><br>Thank you<br><br>Sergey.</p></font><hr class="sig">SergeyThu, 18 Dec 2008 22:07:48 Z2008-12-18T22:07:48Zhttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#ccafccb7-d4cd-4ceb-bff3-132a33096ef1http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#ccafccb7-d4cd-4ceb-bff3-132a33096ef1Bobby Fuhttp://social.msdn.microsoft.com/Profile/en-US/?user=Bobby%20FuException in constructor of object contextSergey, have you solved the problem or find a workaround solution?  I've seen the same exception occurring in my generated code.  I'm looking for a workaround....<br/><br/>Thanks <br/>BobbyFri, 03 Jul 2009 16:16:01 Z2009-07-03T16:16:01Zhttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#a2a4eb30-6b60-4b6d-a8fe-56009c531fb7http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#a2a4eb30-6b60-4b6d-a8fe-56009c531fb7Daniel Simmons - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Daniel%20Simmons%20-%20MSFTException in constructor of object contextCan you give a stack trace?<hr class="sig">This posting is provided &quot;AS IS&quot; with no warranties, and confers no rights.Sat, 04 Jul 2009 07:23:32 Z2009-07-04T07:23:32Zhttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#fe9616db-5441-49fb-8954-2698c290637dhttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#fe9616db-5441-49fb-8954-2698c290637dAsh Eldritchhttp://social.msdn.microsoft.com/Profile/en-US/?user=Ash%20EldritchException in constructor of object context<em>Edit: </em> This error is ONLY thrown if you've explicitly told your debugger to break on CLR exceptions.<br/> <br/> I just started getting this error, after starting to pass a modified connection string to the constructor. The weird thing is I'm now still getting the error even after rolling everything back to the previous code. <br/> <br/> The error is thrown at any of the generated constructors:<br/> <strong>public MyEntities(string connectionString) : base(connectionString, &quot;MyEntities&quot;)</strong> <br/> ...or...<br/> <strong>public MyEntities(global::System.Data.EntityClient.EntityConnection connection) : base(connectionString, &quot;MyEntities&quot;)</strong> <br/> ...or...<br/> <strong>public MyEntities() : base(&quot;name=MyEntities&quot;, &quot;MyEntities&quot;)</strong> <br/> <br/> The Stack Trace in its entirety is<strong>: at System.Reflection.Emit.AssemblyBuilder.GetManifestResourceNames()</strong> <br/> <br/> Even after throwing the error, execution continues and everything works fine as long as you're not debugging.<br/> <br/> <br/> The description for GetManifestResourceNames is illuminating:<br/> <br/> public override string[] GetManifestResourceNames()<br/>     Member of System.Reflection.Emit.AssemblyBuilder<br/> <br/> Summary:<br/> Loads the specified manifest resource from this assembly.<br/> <br/> Returns:<br/> An array of type String containing the names of all the resources.<br/> <br/> Exceptions:<br/> <strong>System.NotSupportedException: This method is not supported on a dynamic assembly. To get the manifest resource names, use System.Reflection.<em>Assembly</em> .GetManifestResourceNames().</strong> <br/> System.Security.SecurityException: The caller does not have the required permission.<br/> <br/> <br/> AshMon, 06 Jul 2009 12:21:24 Z2009-07-07T01:50:18Zhttp://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#080fb1c0-9e93-4622-89c1-ab3c5b7e7524http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b8847ef1-be17-404a-b35f-4b693ca23c58#080fb1c0-9e93-4622-89c1-ab3c5b7e7524Srikanth Mandadi - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Srikanth%20Mandadi%20-%20MSFTException in constructor of object contextBy default the Entity Framework metadata artifacts are included as assembly resources and the connection string includes metadata path similar to &quot;res://*/model.csdl;res://*/model.csdl;res://*/res.msl&quot; when you build an EF application through VS. The &quot;res://*&quot; tells the EF runtime that the metadata files are in one of the referenced assemblies as an embedded resource.  During runtime, EF tries to find the metadata resources by walking the referenced assemblies. But the above exception is hit if one of the assemblies in this list is a dynamic assembly. In this case, we catch the exception and continue since in .Net 3.5 we did not have a clean way to determine if an Assembly is Dynamic. But in .Net 4.0( VS 2010), a property has been added on Assembly class which can be used to determine if an assembly is a dynamic one. So this issue has been fixed in VS 2010 Beta 1 by checking if an assembly is dynamic before calling the GetManifestResourceNames method. <br/>One way to work around the problem in VS 2008 is to change the metadata paths in the connection string to point to a specific assembly rather than *. <br/>ex: <pre class=libCScode style="word-break:break-all;word-wrap:break-word">Metadata=res://AdventureWorks, 1.0.0.0, neutral, a14f3033def15840/model.csdl| res://AdventureWorks, 1.0.0.0, neutral, a14f3033def15840/model.ssdl| res://AdventureWorks, 1.0.0.0, neutral, a14f3033def15840/model.msl</pre> Thanks<br/>Srikanth<hr class="sig">This posting is provided &quot;AS IS&quot; with no warranties, and confers no rights.Tue, 07 Jul 2009 07:02:11 Z2009-07-07T07:02:11Z