Hi all,
Requesting all in helping me on the below question urgently. It will save me big time.
I have a c# COM module which will take a string and writes to a file. It had to be COM, since it has to get the input from asp.net (.NET 2.0) VB code. I have developed the module and works fine in standalone mode. I have registered the COM Dll
using regasm and put it in GAC.
So these are the cases it works,
1) I am able to connect to the C# COM from asp.net using C#.
But when the asp.net page uses VB, it is failing to connect by giving the following error,
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 10: Dim es As Object
Line 11: es = Server.CreateObject("Skmc.MessageWriter")Line 12: es.Send("Hahahahah")Line 13: End Sub
Line 14: </script> |
Source File: C:\Users\sk\Documents\Visual Studio 2012\WebSites\TestKTKSite\Default.aspx
Line:12
Stack Trace:[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.VisualBasic.CompilerServices.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags) +199
Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure) +233
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn) +247
ASP.default_aspx.Enqueue() in C:\Users\sk\Documents\Visual Studio 2012\WebSites\TestKTKSite\Default.aspx:12
ASP.default_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in C:\Users\sk\Documents\Visual Studio 2012\WebSites\TestKTKSite\Default.aspx:26
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266 |
Please find the C# COM module public method definition,
[Guid("9A44E3E1-C71F-456F-8CD6-DE23421ACC11")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _MessageWriter
{
[DispId(1)]
int Send(String message);
}
[Guid("162361AE-B4FC-47D1-BC65-56453F6A0B64")]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("Skmc.MessageWriter")]
[ComVisible(true)]
public class MessageWriter : _MessageWriter
{
Also please find the way i call from asp.net,
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script runat="server">
Sub Enqueue()
Dim es As Object
es = Server.CreateObject("Skmc.MessageWriter")
es.Send("Hahahahah")
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
Hi This is a test web page!!!
</div>
</form>
</body>
</html>
<%
Enqueue
%>
Kindly requesting to help me here.