Hi All,

I am trying to run MSTest unit tests in Visual Studio 2008 that deploy and
run SQL CLR assemblies as part of this process. This generally works fine,
but I have an added complication of wanting to get code coverage statistics.
I have set PERMISSION_SET = UNSAFE, and I am using a user instance of SQL
Server 2008 R2 Express.



When trying to run code coverage over the assemblies, I get the following
error.



Test method ... threw exception:  System.Data.SqlClient.SqlException: An
error occurred in the Microsoft .NET Framework while trying to load assembly
id 66428. The server may be running out of resources, or the assembly may
not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the
query again, or check documentation to see how to solve the assembly trust
issues. For more information about this error:

System.IO.FileLoadException: Could not load file or assembly '<myassembly>'
or one of its dependencies. The given assembly name or codebase was invalid.
(Exception from HRESULT: 0x80131047)

System.IO.FileLoadException:

   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&
stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection)

   at System.Reflection.Assembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection)

   at System.Reflection.Assembly.Load(String assemblyString)

.





After using FusionLogViewer I discovered that there are some binding
failures for the following assemblies

Microsoft.VisualStudio.QualityTools.AgentObject.dll

Microsoft.VisualStudio.QualityTools.Common.dll

Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll

Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter.dll

Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll



After setting the DeploymentItem attribute to deploy these dll's when I run
the unit tests, I still get the same error, but FusionLogViewer no longer
complains about binding failures.



If I run the same unit tests in debug mode, the unit tests pass, but code
coverage is disabled.



Is it just a limitation with Visual Studio 2008 and SQL CLR that I can't
instrument an assembly and have it run inside SQL Server Express. Could it
be a user instance thing?


-- 
Scott Baldwin
Senior Developer - QSR International <http://www.qsrinternational.com>

blog: http://sjbdeveloper.blogspot.com

Reply via email to