2

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.

2
  • I think you'll need to provide more details on this. are you sure you are only deploying the one project you need to? I would try to strip down the solution to just one project and one procedure to deploy. Are you using SQL Data types? Commented Nov 25, 2014 at 19:26
  • It's a simple two project solution. Project A has a reference to Project B. Project B does not contain any code, just a web service reference, yet the error claims that the project with only a web service has a static field. No SQL Datatypes are being used. Commented Nov 25, 2014 at 19:42

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Could it be you incidentally also did a Release build for the deployment?
No, nothing else changed, only the UNSAFE setting for the referenced project.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.