If you're developing procedural code, UDTs, or UDAggs in SQLCLR for SQL Server 2005, Visual Studio 2005 has these nice auto-deploy projects called SQL Server projects that you can use. Comes with templates for each SQL Server 2005 item you can develop, just choose a SQL Server and database at project creation and hit “Deploy” menu entry when you're ready. F5 debugging is even built in to them. VERY cool.
But…there are some folks that don't want any help. Or have an existing class library they want to try. Or want to start from first principals and show others how to install a .NET assembly “by hand”. In Visual Studio Alpha/SQL Server 2005 Beta1 you could do this with a default class library project. In VS Beta1, you can't because there are mutable statics in the class library project “by default”. You have to install it as UNSAFE. Or….
1. Create a new class library project.
2. Click "show all files".
3. Look under Properties (C# project) or MyProject (VB.NET project)
4. Delete Resources.resx and Settings.settings. If you are working in VB.NET project you do NOT have to delete MyApplication.myapp.
5. You're good to go. Just code it up and manually deploy as SAFE (the default).
2 Responses to Using “ordinary” class libraries with SQL Server 2005
What I’ve noticed on occasions is that, if I go through all of the tabs in the project settings (I always like to see what they all are) and hit the resources or settings tab (and maybe I’m doing more than just selecting the tab and reading the info, but that’s all that I think I’m doing), the Resources.resx or Settings.settings will "return" to the project. Sounds like the Settings.settings file is back in the project, just delete it again as described above, recompile, and that should fix the message.
I’m seeing a weird error and was passed to this thread. WHen I create a SQL Server project it creates the Assembly Name and namespace root under the name given (there are no initial options to change it). SO, I go ahead and create my stored procedure class module and manually deploy it (instead of using VS.NET). All is well.
BUT, if I attempt to change either the namespace root or the Assembly name in the Project properties window, it compiles, but when I manually deploy, SQL Server gives me an error similar to what you’re talking about with these static variables (specifically within the get_Value method of the auto-generated MySettings.vb file).
Why is this (FYI … I posted this same question on the private newsgroup and was referred to this blog entry by Niels Berglund).