[英]ActiveX component can't create object COM interop
我有一個要求,我必須在經典ASP中的圖像上使用base64編碼
所以我在C#項目中創建了一個非常簡單的類項目,並嘗試使其COM可見,我已經閱讀了有關stackoverflow的所有指南和各種其他問題,但我仍然無法獲取vbscript來創建對象
程序集標記為ComVisible,並標記輸出以注冊COM interop,我的類源:
namespace Crypto
{
[ComVisible(true)]
[Guid("ad491fe9-ade0-46a1-bae0-d407a987a9e9"),ClassInterface(ClassInterfaceType.None)]
public class Base64
{
public Base64() {
//default com exposable constructor
}
public string Base64Encode(string filePath) {
if (!File.Exists(filePath)) return "";
using (Image image = Image.FromFile(filePath))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
}
}
}
在構建之后,我將其注冊為cominterop並且無論如何都要在GAC中使用
regasm *<file path>* /codebase /tlb
gacutil -i *<file path>*
一切都成功登記
當我從測試經典的asp頁面調用時
set obj = CreateObject("Crypto.Base64")
我明白了
Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object: 'Crypto.Base64'
大約7 - 8年前我在.Net 2.0中與ComInterop合作過,一切順利,我無法理解這個案例有什么不對
在我的開發機器上,它是windows 10 pro 64位,目標編譯是4.6.2 Framework
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.