我試圖重新配置一個CLR存儲過程,曾經是一個大型數據庫項目到一個核心邏輯項目和數據庫項目來分離我的顧慮。因此,項目的架構,像這樣:創建程序集失敗,因爲方法不可見 - 但一切都公開
\src
\Company.Core
\CoreCode.cs
\CoreCode2.cs
\Company.Database
\Programmability\Stored Procedures
CmsSelectQueryStoredProcedure.cs
ClrStoredProcedure2.cs
當我嘗試部署項目,我收到了一系列錯誤消息:
CREATE ASSEMBLY for assembly 'MyAssembly' failed because assembly "MyAssembly" failed
verification. Check it the referenced assemblies are up-to-date and trusted (for
external_access or unsafe) to execute in the database. CLR verifier error messages if any
will follow this message.
MyAssembly.Programmability.Stored_Procedures.CmsSelectQueryStoredProcedure::.ctor Method is
not visible.
MyAssembly.Programmability.Stored_Procedures.CmsSelectQueryStoredProcedure::
.ExecuteCmsSelectQuery Method is not visible.
(Many more of these)
的ClrStoredProcedure1.cs包含此代碼:
using System;
using System.Data.SqlClient;
using System.Security;
using Company.Core;
using Microsoft.SqlServer.Server;
[assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel = PartialTrustVisibilityLevel.VisibleToAllHosts)]
namespace KK.Corporate.ServerGroupQuery.Database.Programmability.Stored_Procedures
{
public class CmsSelectQueryStoredProcedure
{
public static CmsDataService _cmsDataService;
public CmsSelectQueryStoredProcedure()
{
_cmsDataService = new CmsDataService();
}
const string InitialCatalog = "master";
const int ConnectTimeout = 10;
[SqlProcedure]
public static void ExecuteCmsSelectQuery(string targetGroup, string query, string targetGroupUserName, string targetGroupPassword)
{/*etc*/}
}
}
這些方法是公開的,我使用一個程序集屬性使它們更加可見。有什麼我失蹤?
啊構造函數 - 菜鳥錯誤!我仍然想知道爲什麼我會收到所有這些「方法不可見」消息。 –
還不確定,因爲迄今爲止,一切都很順利。這就是爲什麼我提到命名空間,只是因爲沒有明顯的跳出來。 –
我會先解決構造函數問題並重新編譯。如果您仍然遇到錯誤,也許嘗試使用更簡單的命名空間名稱,或者根本沒有? –