views:

71

answers:

3

I am trying to use SMO in visual studio 2010 express. Every time I start a new project I have to hunt for the SMO DLLs via Solutions Explorer | Add Reference by browsing for them. How can I get them to show up as one of the options listed by default in the .NET tab?

Better yet, how can I adjust the default console application to include the references and using statements by default when I create a new project.

A: 

To have an assembly that's not part of the framework appear in the .NET tab, you need a registry entry like

HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\ProductName

whose value is a string that names a directory like

c:\Program Files\Reference Assemblies\ProductName\

and then the reference assembly should appear in that folder.

(I am not 100% sure of the correctness of this, but I think it's right.)

Typically a software package will do that step for you, if it's a well-authored set of library components.

Regarding the second question, you'd want to create your own Visual Studio 'project template' that starts you off with those defaults (a web search will hopefully show you the steps).

Brian
This works perfectly. Just to clarify I added a new key under AssemblyFoldersEx and set its (default) string value to C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies
+1  A: 

If you want an assembly to show up in the .NET tab you need to install it into the Global Assembly Cache. You could then create your own Visual Studio template that includes the correct using statements etc.

Dan Diplo
The GAC is a less than ideal way to get an assembly listed there; it's a last resort. GAC is intended for runtime, and this is for the design-time experience.
Brian
GAC is intended for shared libraries. If SMO is such a library then it is appropriate and allows versioning etc. Seems better than hacking the registry, if I understand the question correctly.
Dan Diplo
Being a C# novice I wasn't sure what the GAC was. I referenced in my C# in a Nutshell book and it sounds like it goes above and beyond doing things I don't completely understand right now. The book had several warnings about using adding assemblies to GAC and the C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies directory has 26 individual DLLs to add. The registry hack involves just a copy and paste of the directory and all 26 assemblies then show up in the .NET tab.
The registry is the right way; the GAC is the wrong way. The fact that GAC'd assemblies show up in the Add Reference dialog at all is mostly a historical artifact and kind of a bug.
Brian
+1  A: 

I believe for that you will need to install the SQL Server client side tools to get them to show up in the .NET of your Add Reference dialog. I know it works with VS 2008, it might with VS 2010.

sdtechcomm
I have SQL Server 2008 RC2 Express installed. It was installed after VC# 2010. Unfortunately it didn't add the SMO references to the .NET tab.