Windows 7 x64 版本和 Visual Studio 2010 dll 参考
我曾经使用 Visual Studio 2008。然后我决定采用 Windows 7 x64 和 Visual Studio 2010 在我们的开发周期等中使用新的 IDE 功能。
我们的项目之一是使用 Microsoft.SqlServer.Smo.dll 和相关的一些 SQL还有服务器管理 DLL。当我尝试编译新项目时遇到很多问题。
这是我的问题。
我创建了一个非常简单的控制台项目,然后添加了 Microsoft.SqlServer.Smo.dll 引用,并将一个简单的以下行放入 main() 函数中。
static void Main(string[] args) { Microsoft.SqlServer.Management.Smo.ApplicationRole 角色 = 新的 Microsoft.SqlServer.Management.Smo.ApplicationRole(); }
ApplicationRole
类来自 Microsoft.SqlServer.Smo.dll,我将项目的目标框架属性更改为 .Net Framework 4(不是客户端配置文件)。就编译成功了。
当我尝试将目标框架更改为 .Net Framework 2.0 时,出现错误
错误 1 命名空间“Microsoft.SqlServer.Management.Smo”中不存在类型或命名空间名称“ApplicationRole”(您是吗?缺少程序集引用?) C:\Users\fatihy\documents\visual studio 2010\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs 14 52 ConsoleApplication2
这是我遇到的一个小错误,但我确信其他人也与此问题相关。
当我使用 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>
您可以看到该 dll 支持 .net 2.0 CRL。
示例项目也可以从此处下载
我做错了什么?
谢谢
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.
One of our projects is using Microsoft.SqlServer.Smo.dll and related some SQL server management DLLs also. 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.
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). It compiled successfully.
When I tried to change target framework to .Net Framework 2.0 it's giving error that
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
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,
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.
Sample project can be also downloaded from here
What I'm doing wrong ?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Microsoft.SqlServer.Smo.dll
是在 .Net 3.5 中构建的。如果您的项目目标框架是 .Net Framework 2.0,您根本无法使用它。刚刚在您的演示控制台应用程序中检查了它。
Microsoft.SqlServer.Smo.dll
is build in .Net 3.5. You simply can't use it if your target framework for the project is .Net Framework 2.0.Just checked it in your demo console app.