tags:

views:

314

answers:

2

I have created a C# console application that contains the namespaces System and System.Data

Additionally, I have added Microsoft.SqlServer.Smo.

When I try to compile from command prompt it shows the error as:

SqlSmoDiscovery.cs(3,27): error CS0234: The type or namespace name 'Management' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?) SqlSmoDiscovery.cs(4,27): error CS0234: The type or namespace name 'Management' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

But it compiles from Visual Studio.

I am compiling from command prompt to have output as pure C# dll.

My Project in g:

then i navigate to G:\SqlDisc:> csc /target:library /r Micrsoft.SqlServer.Smo.Dll

SqlSmoDiscovery.cs but it shows the erroe as

error CS0006: Metadata file 'Microsoft.SqlServer.Smo.dll' could not be found

+7  A: 

Use the /r flag to reference additional assemblies from the command line.

csc /target:library /r:OtherAssembly.dll Foo.cs
Jon Skeet
Before that plce the assemblies in the samefolder
Cute
not necessary to place the assemblies in the same folder at compile time. You can reference the assemblies by full path. At runtime, The assemblies need to be accessible: generally either in the local dir or in the GAC. Supposing you reference an assembly that is GAC'd, then you can specify it in the csc.exe command as something like c:\Windows\assembly\GAC\DataGridEx\1.0.1.0__852e0362e1c80f34\DataGridEx.dll. At runtime, the GAC'd assembly will be loaded just fine, without copying it anywhere.
Cheeso
+1  A: 

For more info, see the reference for the csc.exe tool.

Cheeso