से .NET 3.0 कोड निष्पादित करें। मैंने .NET 3.0 ढांचे का उपयोग कर सी # में एक डीएलएल बनाया है।Office 2003
नीचे मेरी DLL का कोड
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;
}
}
}
मैं Office 2003 VBA कोड से चलाने के लिए इस कोड को प्राप्त करने की कोशिश कर रहा हूँ है। डिफ़ॉल्ट विजुअल स्टूडियो 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 ढांचे तक स्थापित है।
यह इस समस्या पर सबसे संक्षिप्त और एकमात्र पूर्ण मार्गदर्शिका है जिसे मैंने काम करने के लिए प्रयास करने के कुछ घंटों बाद पाया। धन्यवाद। –