.NET 3.0 프레임 워크를 사용하여 C#에서 DLL을 만들었습니다.Office 2003에서 .NET 3.0 코드 실행
다음은 내가 Office 2003의 VBA 코드에서 실행하려면이 코드를 얻으려고
namespace CompanyName.Net
{
[Guid("F7075E8D-A6BD-4590-A3B5-7728C94E372F")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("CompanyName.Net.Webrequest")]
public class WebRequest
{
public string Result { get; private set; }
public string Url { get; set; }
public string StatusDescription { get; private set; }
public HttpStatusCode StatusCode { get; private set; }
public WebRequest()
{
//explicit constructor
}
public string GetResponse(string url)
{
System.Net.WebRequest webreq = System.Net.WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse) webreq.GetResponse();
// Store the status.
StatusDescription = response.StatusDescription;
StatusCode = response.StatusCode;
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
Result = reader.ReadToEnd();
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();
//return the response
return Result;
}
}
}
내 DLL의 코드입니다. DLL은 기본 Visual Studio 2008 서명을 사용하여 서명되었습니다.
나는
regasm /tlb c:\CompanyName.Net.dll
를 사용하여 .TLB 파일을 만들어 내 어셈블리를 참조하는 관리하지만 한 나는 개체의 인스턴스를 생성 할 때
Private Sub Command0_Click()
Dim o As Object
Set o = CreateObject("CompanyName.Net.WebRequest")
Dim s As String
s = o.GetResponse("http://www.google.be")
MsgBox s
End Sub
나는 다음과 같은 오류를 :
ActiveX component can't create Object
내가 뭘 잘못하고 있니?
내가 테스트하고있는 컴퓨터에는 .NET 3.5 프레임 워크까지 .NET이 설치되어 있습니다.
이것은 이것이 작동하도록 노력한 몇 시간 후에 발견 한이 문제에 대한 가장 간결하고 완전한 가이드입니다. 고맙습니다. –