简体   繁体   English

在SQL Server 2008 R2中创建程序集时出错

[英]Error Creating Assembly in SQL Server 2008 R2

We are having problems creating an assembly in our database and need some assistance. 我们在数据库中创建程序集时遇到问题,需要一些帮助。 We have two .NET 2.0 assemblies ( ABC.Company.App1.dll and ABC.Company.App2.dll ). 我们有两个.NET 2.0程序集( ABC.Company.App1.dllABC.Company.App2.dll )。 Both assemblies only have references to System, System.Data, and System.XML. 两个程序集仅引用System,System.Data和System.XML。 ABC.Company.App1.dll also references ABC.Company.App2.dll. ABC.Company.App1.dll也引用了ABC.Company.App2.dll。

We're trying to create the ABC.Company.App1.dll assembly using: 我们正在尝试使用以下方法创建ABC.Company.App1.dll程序集:

CREATE ASSEMBLY App1 
AUTHORIZATION dbo 
FROM 'C:\ApplicationPath\ABC.Company.App1.dll' 
WITH PERMISSION_SET = SAFE
GO

Note both assemblies are in C:\\ApplicationPath. 请注意,两个程序集都在C:\\ ApplicationPath中。

But this fails. 但这失败了。 The error is: 错误是:

Msg 10300, Level 16, State 1, Line 21 Assembly 'ABC.Company.App1' references assembly 'ABC.Company.App2, version=0.0.0.0, culture=neutral, publickeytoken=null.', which is not present in the current database. Msg 10300,Level 16,State 1,Line 21 Assembly'ABC.Company.App1'引用程序集'ABC.Company.App2,version = 0.0.0.0,culture = neutral,publickeytoken = null。',它不存在于当前数据库。 SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: version, culture or public key mismatch). SQL Server尝试从引用程序集来自的相同位置定位并自动加载引用的程序集,但该操作失败(原因:版本,区域性或公钥不匹配)。 Please load the referenced assembly into the current database and retry your request. 请将引用的程序集加载到当前数据库中,然后重试您的请求。

What's the problem? 有什么问题? How can we fix this? 我们该如何解决这个问题?

The version of ABC.Company.App2 is definitely not 0.0.0.0. ABC.Company.App2的版本绝对不是0.0.0.0。 We've tried creating the ABC.Company.App2 assembly into our database first, which succeeds, but trying to create ABC.Company.App1 assembly still fails. 我们首先尝试将ABC.Company.App2程序集创建到我们的数据库中,但是尝试创建ABC.Company.App1程序集仍然失败。 A little more info. 多一点信息。 We've tried with PERMISSION_SET = SAFE, UNSAFE, and EXTERNAL_ACCESS, none of which work. 我们尝试过使用PERMISSION_SET = SAFE,UNSAFE和EXTERNAL_ACCESS,但都没有。 And, these DLLs are not strongly named and are not registered in the GAC. 并且,这些DLL没有强名称,也没有在GAC中注册。

Help?! 救命?!

Thanks! 谢谢!

Sounds like you are trying to create assembly ABC.Company.App1.dll which references ABC.Company.App2.dll but, since ABC.Company.App2.dll hasn't been created yet, you're getting an error. 听起来你正在尝试创建程序集ABC.Company.App1.dll,它引用了ABC.Company.App2.dll但是,由于还没有创建ABC.Company.App2.dll,所以你收到一个错误。 Try creating ABC.Company.App2.dll first. 首先尝试创建ABC.Company.App2.dll。

I had this problem and I eventually worked it out. 我有这个问题,我最终解决了这个问题。 I was referencing an x86 assembly on a 64 bit server. 我在64位服务器上引用了x86程序集。 I rebuilt the referenced assembly as Any CPU, installed in on the server, re-added the reference to the project, rebuilt my project as Any CPU, and then SQL Server could resolve the reference and install the assembly. 我将引用的程序集重建为Any CPU,安装在服务器上,重新添加对项目的引用,将项目重建为Any CPU, 然后 SQL Server可以解析引用并安装程序集。

A message along the lines of "You're referencing an assembly that's built for the wrong platform" would have been rather useful :) “您正在引用为错误平台构建的程序集”的消息将非常有用:)

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

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