C# 和 Sparx EA 互操作库 - 未找到方法
C# and Sparx EA interop lib - method not found
尝试使用此处描述的方法 RepositoryType()
编译 C# 代码
http://sparxsystems.com/enterprise_architect_user_guide/13.0/automation/repository3.html
我遇到了这个错误
Error CS1061 'Repository' does not contain a definition for 'RepositoryType' and no extension method 'RepositoryType' accepting a first argument of type 'Repository' could be found (are you missing a using directive or an assembly reference?)
我尝试 cleaning/rebuiling 所有东西,但它不起作用。此外,在运行时调用看起来不错 - returns string.
有什么帮助?
更新:
使用和分配
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using EA;
using MSScriptControl;
public class SparxEaDocGenScriptRunner
{
private MSScriptControl.ScriptControl _msScriptControl;
private EA.Repository _repository;
private string _language;
private string _databaseType;
private Regex _eaLanguageDeterm;
private Regex _getExtFromName;
private IDictionary<string, string> _languageExts;
/// <summary>
/// Add-in logger accessor.
/// </summary>
private ApplicationLogger _logger;
public SparxEaDocGenScriptRunner(Repository repository, ApplicationLogger logger)
{
_repository = repository;
_logger = logger;
var connectionString = _repository.ConnectionString;
var type = _repository.RepositoryType();
}
//...
}
它从这部分代码一直注入,比方说,Main.cs
:
public void EA_MenuClick(EA.Repository Repo, string Location, string MenuName, string ItemName)
{
switch (ItemName)
{
case MENU_DOC_GEN:
#region Logging Statement
Logger.Write(new LogEntry
{
Severity = TraceEventType.Information,
Message = "Loading Document Generator",
Categories = new[] { ApplicationConstants.DocumentGeneratorLogCategory }
});
#endregion
DocumentGenerator docgen = new DocumentGenerator(Repo);
docgen.ShowDialog();
break;
case MENU_ABOUT:
new AboutBox().Show();
break;
}
}
UPD2:
我的EA.Interop.dll
版本:
我写信支持,在此处引用了我的问题,并得到了答案 :) 它真的很有帮助。又是我太粗心了
Hi Danil,
Thank you for your enquiry.
It's possible that you are referencing an older version of the
EA.Interop.dll file which did not yet contain this function. We could
see in your screenshot that you are referencing this Interop DLL from
somewhere under "C:\Users\temp1...".
Please note that the version number of the EA.Interop.dll file doesn't
get updated between EA versions, it is generally more useful to look
at the created/modified timestamp on the file. What are the timestamps
on the Interop DLL file you are referencing and the one in your
current EA install directory? (default: C:\Program Files (x86)\Sparx
Systems\EA)
I would suggest either changing your reference to point directly to
the DLL from your current EA installation, or copy the current version
from your EA install directory and overwrite the location where your
dll is being referenced from.
Best regards,
Aaron Bell
Sparx Systems Pty Ltd
support@sparxsystems.com
好吧,所以我重新安装了 Sparx EA,从安装文件夹中复制了 .dll,它成功了!
尝试使用此处描述的方法 RepositoryType()
编译 C# 代码
http://sparxsystems.com/enterprise_architect_user_guide/13.0/automation/repository3.html
我遇到了这个错误
Error CS1061 'Repository' does not contain a definition for 'RepositoryType' and no extension method 'RepositoryType' accepting a first argument of type 'Repository' could be found (are you missing a using directive or an assembly reference?)
我尝试 cleaning/rebuiling 所有东西,但它不起作用。此外,在运行时调用看起来不错 - returns string.
有什么帮助?
更新:
使用和分配
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using EA;
using MSScriptControl;
public class SparxEaDocGenScriptRunner
{
private MSScriptControl.ScriptControl _msScriptControl;
private EA.Repository _repository;
private string _language;
private string _databaseType;
private Regex _eaLanguageDeterm;
private Regex _getExtFromName;
private IDictionary<string, string> _languageExts;
/// <summary>
/// Add-in logger accessor.
/// </summary>
private ApplicationLogger _logger;
public SparxEaDocGenScriptRunner(Repository repository, ApplicationLogger logger)
{
_repository = repository;
_logger = logger;
var connectionString = _repository.ConnectionString;
var type = _repository.RepositoryType();
}
//...
}
它从这部分代码一直注入,比方说,Main.cs
:
public void EA_MenuClick(EA.Repository Repo, string Location, string MenuName, string ItemName)
{
switch (ItemName)
{
case MENU_DOC_GEN:
#region Logging Statement
Logger.Write(new LogEntry
{
Severity = TraceEventType.Information,
Message = "Loading Document Generator",
Categories = new[] { ApplicationConstants.DocumentGeneratorLogCategory }
});
#endregion
DocumentGenerator docgen = new DocumentGenerator(Repo);
docgen.ShowDialog();
break;
case MENU_ABOUT:
new AboutBox().Show();
break;
}
}
UPD2:
我的EA.Interop.dll
版本:
我写信支持,在此处引用了我的问题,并得到了答案 :) 它真的很有帮助。又是我太粗心了
Hi Danil,
Thank you for your enquiry.
It's possible that you are referencing an older version of the EA.Interop.dll file which did not yet contain this function. We could see in your screenshot that you are referencing this Interop DLL from somewhere under "C:\Users\temp1...".
Please note that the version number of the EA.Interop.dll file doesn't get updated between EA versions, it is generally more useful to look at the created/modified timestamp on the file. What are the timestamps on the Interop DLL file you are referencing and the one in your current EA install directory? (default: C:\Program Files (x86)\Sparx Systems\EA)
I would suggest either changing your reference to point directly to the DLL from your current EA installation, or copy the current version from your EA install directory and overwrite the location where your dll is being referenced from.
Best regards,
Aaron Bell
Sparx Systems Pty Ltd
support@sparxsystems.com
好吧,所以我重新安装了 Sparx EA,从安装文件夹中复制了 .dll,它成功了!