- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 RegAsm 注册一个 .dll。它是一个 .NET 2.0 dll。所有类都是公开的,ComVisible 为真。我仍然收到 RA0000:没有注册类型错误。下面是代码和程序集信息。任何帮助都会很棒,谢谢!
STARTelnet.cs
/**
*Steven T. Norris Created: 3/27/2012
*Last Updated By: Steven T. Norris Last Updated On: 3/27/2012
*
*/
using System;
using MinimalisticTelnet;
using System.Net.Sockets;
/**
* @brief Used to connect to, read, and respond to a STAR terminal session.
*
* Steven T. Norris Created: 3/27/2012
*/
namespace STARTelnet
{
/**
* Class used to connect to, read, and respond to a STAR terminal session.
*/
public class STARConnection
{
private TelnetConnection conn;
private string output;
private string command;
private string prompt;
/**
* Instantiates new STARConnection. <br/>
* Recommended login timeout is 2000. <br/>
* Recommended overall timeout is 500. <br/>
* Throws SocketException, PromptException, LoginException
*
* @param [in] string username:Username for login
* @param [in] string password:Password for login
* @param [in] int loginTimeout:timeout milliseconds for login
* @param [in] int overallTimeout:timeout milliseconds for session
*/
public STARConnection(string username, string password, int loginTimeout, int overallTimeout)
{
output = "";
conn = new TelnetConnection("HOSTHOSTHOST", 23);
this.SetTimeout(overallTimeout);
try
{
output = conn.Login(username, password, loginTimeout);
if(output.Contains("You entered an invalid login name or password"))
{
throw new LoginException("Failed to login");
}
this.ParsePrompt();
}
catch(Exception e)
{
if(e.Message.Contains("login prompt"))
{
throw new PromptException("Login", "Could not find login prompt");
}
else if(e.Message.Contains("password prompt"))
{
throw new PromptException("Password", "Could not find password prompt");
}
else
{
throw e;
}
}
}
/**
* Sets the timeout for the session in milliseconds
* @param [in] int timeout:timeout for session
*/
public void SetTimeout(int timeout)
{
conn.MainTimeOutMs = timeout;
conn.TimeOutMs = timeout;
}
/**
* Gets the current timeout for the session in milliseconds
* @param [out] int:timout for session
*/
public int GetTimeout()
{
return conn.TimeOutMs;
}
/**
* Writes a command to the STAR session
* @param [in] string command:command to write
*/
public void Write(string command)
{
this.command = command;
conn.Write(this.command);
this.command = this.command.Replace("\n", "{newLine}");
}
/**
* Writes a command followed by a new line (\n) to the STAR session
* @param [in] string command:command to write
*/
public void WriteLine(string command)
{
this.command = command;
conn.WriteLine(this.command);
this.command += "{newLine}";
}
/**
* Reads output from STAR session. Assumes no data within given timeout denotes end of stream
* @param [out] string:output from STAR session
*/
public string Read()
{
output = conn.Read();
this.ParsePrompt();
return output;
}
/**
* Reads output from STAR session with timeout changed for only this read. Assumes no data within
* timeout denotes end of stream.
* @param [in] int timeout:timeout for this read only
* @param [out] string:output from STAR session
*/
public string Read(int timeout)
{
int temp = this.GetTimeout();
this.SetTimeout(timeout);
this.Read();
this.SetTimeout(temp);
return output;
}
/*
* Parse prompt from output
*/
private void ParsePrompt()
{
prompt = output.Substring(output.LastIndexOf("\n") + 1);
}
/**
* Gets output from last read
* @param [out] string:output from last read
*/
public string GetOutput()
{
return output;
}
/**
* Gets last command entered
* @param [out] string:last command entered
*/
public string GetCommand()
{
return command;
}
/**
* Gets prompt from last read
* @param [out] string:last prompt
*/
public string GetPrompt()
{
return prompt;
}
/**
* Checks for connection
* @param [out] bool:connection status
*/
public bool IsConnected()
{
return conn.IsConnected;
}
}
/**
* Exception for failed logins
*/
class LoginException: Exception
{
private string offender = "";
public LoginException() : base() { }
public LoginException(string message) : base(message) { }
/**
* Creates exception
* @param string offender:element causing exception
* @param string message:exception message
*/
public LoginException(string offender, string message)
: base(message)
{
this.offender = offender;
}
/**
* To String method for getting exception string
* @param [out] string:string representation of exception
*/
public override string ToString()
{
if(offender == "")
{
return this.GetType() + ": "+this.Message+"\n"+this.StackTrace;
}
else
{
return "Incorrect login: " + offender + "--" + this.Message + "\n" + this.StackTrace;
}
}
}
/**
* Exception for failed STAR prompts
*/
class PromptException: Exception
{
private string prompt = "";
public PromptException() : base(){ }
public PromptException(string message) : base(message){ }
/**
* Creates exeption
* @param string prompt:prompt causing exception
* @param string message:exception message
*/
public PromptException(string prompt, string message)
: base(message)
{
this.prompt = prompt;
}
/**
* To String method for getting exception string
* @param [out] string:string representation of exception
*/
public override string ToString()
{
if(prompt == "")
{
return this.GetType() + ": " + this.Message + "\n" + this.StackTrace;
}
else
{
return "Prompt failed: " + prompt + "--" + this.Message + "\n" + this.StackTrace;
}
}
}
}
AssemblyInfo.cs
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("STARTelnet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("COMPANY")]
[assembly: AssemblyProduct("STARTelnet")]
[assembly: AssemblyCopyright("Copyright © COMPANY 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d7ae512d-c840-4ebc-8057-73a10f286225")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
最佳答案
我认为你的问题是你没有默认构造函数。请添加以下代码并调用。这是基于 guidance from MSDN .
调用代码(当然在 COM 中看起来会有所不同)
var connection = new STARConnection();
connection.Initialize(username, password, loginTimeout, overallTimeout);
新代码
/// <summary>
/// Default constructor needed for COM. Set parameters with properties.
/// </summary>
public STARConnection()
{
}
public Initialize(string username, string password, int loginTimeout, int overallTimeout)
{
output = "";
conn = new TelnetConnection("HOSTHOSTHOST", 23);
this.SetTimeout(overallTimeout);
try
{
output = conn.Login(username, password, loginTimeout);
if(output.Contains("You entered an invalid login name or password"))
{
throw new LoginException("Failed to login");
}
this.ParsePrompt();
}
catch(Exception e)
{
if(e.Message.Contains("login prompt"))
{
throw new PromptException("Login", "Could not find login prompt");
}
else if(e.Message.Contains("password prompt"))
{
throw new PromptException("Password", "Could not find password prompt");
}
else
{
throw e;
}
}
}
关于c# - RegAsm dll 没有类型注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9977349/
我有一个问题,想知道如何在已经使用常规登录/注册系统的网站上集成第 3 方登录(也进行静默注册)。 基本上当前登录还是比较规律的: 当用户进入网站 session 时类(class)决定他是否需要重新
我在学习 Hyperledger Fabric 并运行示例代码。 我仍在尝试正确了解事情的运作方式,尤其是在使用证书和加密 Material 的用户/管理员注册和注册中。 我想知道以下如何工作。 1)
我正在尝试使用从我的 Android 设备的 PassWallet 应用程序中保存的票证中获取的 token 向我的设备发送消息。 设备发送使用苹果钱包规范更新通行证所需的所有信息。但是,我正在使用
使用 Passport 本地示例,我可以登录工作。没有关于如何注册用户的文档。 我想为用户提供一个“电子邮件”和“密码”字段,他们可以使用它们来注册该网站。我怎样才能做到这一点?有什么原因没有记录下来
在之前的一些 WSO2IS 版本中,有一个默认的 self 注册功能。但是,我在 5.0 版本中找不到它。 阅读 WSO2IS 5.0 文档,我发现有 2 个用于此功能的 API: getUserId
我已将 Airship SDK 集成到 Android 应用程序中。在应用程序启动和飞艇起飞后,我在日志中得到以下调试信息: 07-27 12:46:31.916 XXX - UALib( 1545)
Delphi 中设计时包的可怕错误之一是以下错误,这意味着注册安装新组件到您的 Palette 上的包: Component TSomething can't be registered by pac
我发现的大部分内容都使用 php 或类似的东西。 我有一个 Angular 前端和 Node/express 服务器代码。还没有后端。我不确定如何继续用户注册。 最佳答案 在没有后端的情况下进行注册等
我正在使用 Drupal 6 开发一个网站。我正在使用我自己的主题,并且一切正常。现在我需要使用我的自定义主题在我的网站上创建一个自定义登录/注册表单。我尝试了很多方法,但一切都重定向到我的管理主题,
我在运行此代码时收到 Sip 异常。这是因为 manager.register(me,20,listener)。 下面是我的代码,所以请帮我更正这段代码。我正在使用 SipDemo 代码注册我的帐户。
在过去的几天里,我一直在尝试为基于 VUE 的 excel 制作任务 Pane 插件。 我已按照 link 的指南进行操作我试图为 onSelectionChange 注册一个事件处理程序。它已经有些
我需要在使用 django-registration 应用程序的登录表单中实现一个“记住我”按钮。任何ane可以帮助我向我展示这样做的方法吗? 谢谢 最佳答案 一种方法是更改 session 到期
我发现,如果您使用 Django 1.5 版本,则 django 注册模块会中断,因为在最新的 django 开发版本中,simple.py 类已被删除。 最佳答案 此问题现已修复: hg clone
我正在尝试将 facebook connect 实现到我的网站,但有几个问题。 1:是否可以使用用户当前的 Facebook 电子邮件/密码在我的网站上注册用户。 假设用户点击链接通过 faceboo
我使用 Facebook 注册来允许人们在我的网站上注册。有没有可能,在注册后,他在我的网站注册的成员(member)墙上会张贴? 最佳答案 这可能不是您正在寻找的答案,但我强烈建议您不要这样做。用户
I would like to use a slash (/) for a search during a vimscript, but I don't want to overwrite the "
我正在使用 jqgrid 并且有显示日期的列,但是来自服务器的日期以 json 格式出现,如下所示, "CommentedDate": "\/Date(1304324941000+0530)\/" 如
我希望用户可以直接登录主页,而不是在“../account/login/”页面上登录。我应该做什么才能使它成为可能?如何将主页上的输入字段与 allauth 连接?我不知道这样是否太复杂而无法以这种方
This question already has answers here: Understanding NSString comparison (7个答案) 5年前关闭。 我正在尝试制作注册表。有
我正在使用 Django 注册。它提供了处理 registration_form.html 的 View ,该 html 当前包含用户名、密码 1、密码 2 和电子邮件作为我的应用程序中的用户可输入字
我是一名优秀的程序员,十分优秀!