Problem solve Get help with specific problems with your technologies, process and projects.

Getting 'InvalidCastException: QueryInterface for interface' error when I call it in my aspx page

I am getting an error -- "InvalidCastException: QueryInterface for interface" -- when I call it in my ASPx page. But it works fine when I call it in VB6, and I have a DLL created using VB6. When I call the same in a .NET application, it gives me System.InvalidCastException:QueryInterface for interface Projectname.ClassName failed. I have registered the DLL in all the boxes. In ASP, I call the function like this:

 "Set objIsam = server.CreateObject("NBPIsamFileAccess.ReadRecord")
With objIsam
	.UserType = "TYPE"
	.UserID = "ID"
	.UserDomain = "DOMAIN"
	.PdcrState = ""
	.PdcrCode = ""
End With

blnOK = objIsam.ReadCIACCTT0("04202","C","Smith","",objRst1)"

It worked fine. I used the same DLL in ASPx page, but it is not working. In the ASPx page, I first added reference to the project, from select/project then COM tab, then I selected the corresponding DLL and created the runtime callable wrapper using .NET SDK environment. Then I used it like this in the ASPx:

When I ran it, I got above error at line .UserType = "TYPE" in the beginning of With statement. Please advise me. Thanks.
You're not doing a New() on the class for the myNBPIsam variable. That could be the problem.

Dig Deeper on ASP.NET and Ajax development

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.