【发布时间】:2017-04-29 21:05:04
【问题描述】:
我已按照此问题中描述的步骤进行操作:
所以,我有这个 c# 代码:
using System;
using System.IO;
namespace ComLib
{
public class LogWriter
{
public void WriteLine(string line)
{
using (var log = new StreamWriter(File.OpenWrite(@"c:\log.file")))
{
log.WriteLine(line);
}
}
}
}
在名为:RubyToCSharp的解决方案下
我在 VS 中检查了 Register for COM interop 并创建了以下 ruby 代码:
require "win32ole"
lib = WIN32OLE.new('RubyToCSharp.ComLib.LogWriter')
lib.WriteLine('calling .net from ruby via COM, hooray!')
现在我尝试从 powerShell 运行此 ruby,但我不断收到此错误:
./exmpl.rb:4:in `initialize': unknown OLE server: `RubyToCSharp.ComLib.LogWriter' (WIN32OLERuntimeError)
HRESULT error code:0x800401f3
Invalid class string
from ./exmpl.rb:4:in `new'
from ./exmpl.rb:4:in `<main>'
对我在这里错过了什么有什么想法吗?
编辑
检查我的dll是否根据this SO question注册后, 看来我的 dll 确实已注册,但仍然发生同样的错误。
这里真是一头雾水……
【问题讨论】: