Reputation: 181
I have a CLR Package made using VB.NET in Visual Studio 2012 that I'm trying to deploy to a SQL Server 2012 database. The solution has two projects, one that will be the CLR and another that is referencing a Web Service. Anytime I try to deploy to SQL, I get the following error
(47,1): SQL72014: .Net SqlClient Data Provider:
Msg 6211, Level 16, State 1, Line 1
CREATE ASSEMBLY failed because type 'SSRSService.ReportExecutionService.ReportExecutionService' in safe assembly 'SSRSService' has a static field '__ENCList'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language.
An error occurred while the batch was being executed.
I've already ensured that the project has the Permission level UNSAFE and that TRUSTWORTHY is ON for the SQL Server.
The weird thing is that the field it's claiming to be the problem doesn't even exist! The project that it's complaining about only contains a Web Service reference and nothing more.
Upvotes: 2
Views: 3187
Reputation: 9065
Searching for this field's name, showed me a worked around, provided by Microsoft MVP Dan Guzman: Assembly Insert brings static field error, but I have no fields
The VB.NET compiler references an internal helper class with a static field so you won't be able to create the assembly from a VB.NET debug build. Try building and deploying a release build instead (or use C#).
Should be worth a try.
Upvotes: 0
Reputation: 181
I've been able to solve the problem. I had missed a single step when I made the reference from the Startup project to the Web Service project.
All I had to do was expand the References node in the Project Explorer for the Startup project and select the Project Reference. From there, go to the Properties window and set the property Permission Set to Unsafe.
Upvotes: 1