简体   繁体   English

Windows 7 x64 Edition和Visual Studio 2010 dll参考

[英]Windows 7 x64 Edition and Visual Studio 2010 dll reference

I used to use Visual Studio 2008. Then I decided to take Windows 7 x64 and Visual Studio 2010 to use new IDE features inside of the our development cycle etc. 我曾经使用Visual Studio2008。然后我决定使用Windows 7 x64和Visual Studio 2010在我们的开发周期等中使用新的IDE功能。

One of our projects is using Microsoft.SqlServer.Smo.dll and related some SQL server management DLLs also. 我们的项目之一是使用Microsoft.SqlServer.Smo.dll,并且还关联了一些SQL Server管理DLL。 I got many problems when I tried to compile new projects. 尝试编译新项目时遇到很多问题。

Here is the my problem. 这是我的问题。

  • I create a very simple console project, then I added Microsoft.SqlServer.Smo.dll reference and I put a simple below line into main() function. 我创建了一个非常简单的控制台项目,然后添加了Microsoft.SqlServer.Smo.dll参考,并在main()函数中添加了一个简单的下面行。

      static void Main(string[] args) { Microsoft.SqlServer.Management.Smo.ApplicationRole role = new Microsoft.SqlServer.Management.Smo.ApplicationRole(); } 

ApplicationRole class is coming from Microsoft.SqlServer.Smo.dll, I changed Target framework property of project to .Net Framework 4 (not client profile). ApplicationRole类来自Microsoft.SqlServer.Smo.dll,我将项目的目标框架属性更改为.Net Framework 4(而不是客户端配置文件)。 It compiled successfully. 它编译成功。

When I tried to change target framework to .Net Framework 2.0 it's giving error that 当我尝试将目标框架更改为.Net Framework 2.0时,出现了以下错误

Error 1 The type or namespace name 'ApplicationRole' does not exist in the namespace 'Microsoft.SqlServer.Management.Smo' (are you missing an assembly reference?) C:\\Users\\fatihy\\documents\\visual studio 2010\\Projects\\ConsoleApplication2\\ConsoleApplication2\\Program.cs 14 52 ConsoleApplication2 错误1类型或名称空间名称'ApplicationRole'在名称空间'Microsoft.SqlServer.Management.Smo'中不存在(您是否缺少程序集引用?)C:\\ Users \\ fatihy \\ documents \\ visual studio 2010 \\ Projects \\ ConsoleApplication2 \\ ConsoleApplication2 \\ Program.cs 14 52 ConsoleApplication2

That's the small one of errors what I have, but I'm sure others related with this issue. 那只是我所犯错误的一小部分,但是我敢肯定其他人与此问题有关。

When I checked Microsoft.SqlServer.Smo.dll with corflags tool see below, 当我使用corflags工具检查Microsoft.SqlServer.Smo.dll时,请参见下文,

Setting environment for using Microsoft Visual Studio 2010 x86 tools.

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>corflags "C:\Program File
s\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.Smo.dll"
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 9
ILONLY    : 1
32BIT     : 0
Signed    : 1

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>

As you can see this dll is supporting .net 2.0 CRL. 如您所见,该dll支持.net 2.0 CRL。

Sample project can be also downloaded from here 样本项目也可以从这里下载

What I'm doing wrong ? 我做错了什么?

Thank you 谢谢

Microsoft.SqlServer.Smo.dll is build in .Net 3.5. Microsoft.SqlServer.Smo.dll是在.Net 3.5中构建的。 You simply can't use it if your target framework for the project is .Net Framework 2.0. 如果项目的目标框架是.Net Framework 2.0,则根本无法使用它。

Just checked it in your demo console app. 只需在演示控制台应用程序中进行检查即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM