COM object not working after migrating to IIS 7.5 - dll

I am moving a classic ASP application from IIS6 to IIS7.5 and I am having troubles with COM dependencies.
This is the problematic code
SET o = Server.CreateObject("ClassName")
Response.Write "Returned object: " & TypeName(o)
result = o.SomeMethod()
The first line succeeds, the second line prints "Returned object: ClassName".
The third line ends with an error
Error: 429
Source: Provider
Description: Class not registered
I don't know, whether that is a 32 x 64 bit issue (the server is 64bit, the old one was 32bit). But I did set the "Enable 32-Bit Application" property of the application pool to True.
Is it normal that Server.CreateObject returns an object and it is the method call that actually fails?
We are using WIX script to register the COM classes (I did not do any modifications in this part).
I can find my class in the registry in Computer\HKEY_CLASSSES_ROOT\Wow6432Node.
I would appreciate any pointers, this drives me crazy.

You have got an instance of ClassName. No error on object creation and TypeName confirms it. So, the component is correctly registered.
But, does it reference another component which is used from the method you are calling? It seems a not controlled error raises from inside your class.

Related

Calling COM component method from IBM Notes 9 fails

When calling a 32 bit COM component method registered in sysWOW64 fails with an error message:
"type mismatch in method OleVarToLsVal, Unknown found, Unknown
expected"
Its win7 64 bit, but the Notes client is installed by default as a 32 bit application. The code looks like:
dim c as Variant
dim n as Variant
set c = createobject("MSWC.counters")
n = c.Get("xx")
When debugging the call, the object is set and testable with "isObject(c)", (although you can't inspect each method/property in detail in LotusScript debug).
The method is supposed to return a primitive long. I've tried setting n as long, clng-ing the values, cstr-ing the values, the parameter, strconv the parameter, using a variable for the parameter, all to no avail.
The exact same code run by WScript VBS host (in syswow64) runs the code as expected.
So, does anybody know:
If Notes 9 COM value marshalling is working for any components?
Is Notes 9 COM set to recognize the 'wow64' alternate 32 bit registry
Are there some COM related marshalling settings somewhere in the registry I can check (if so what/where are they)?
Is there some setting to tell Notes to use 32 bit components (like IIS 32bit compatibility option)
Is there anything I need to do or could do in the main OS to 'redirect or configure' COM
Or is Notes just broken again and nobody cares?
Any help appreciated - Thanks.
The easiest and probably most productive way to solve this would be to open a PMR with IBM. They should be able to answer this quite quickly.
Well, 7 years on (and seriously obsolete!) just an update for anybody looking for an answer... There are a couple of Notes settings needed and not all COM/Active-X componenets or data types are supported by LotusScript, so even if Notes is setup correctly, you still may not be able to acces/use any specific component or some methods in the component.
The user must be allowed to run unrestricted agents/code in the 'Sign or run unrestricted methods and operations:' in the security section of the server(s) document.
The Notes client execution control list ('ECL') must allow access to 'External programs' either by default or to the code-signer. An ECL warning box will ask the user to continue if the external access has not been granted.
If you try to execute an unsupported method or unsupported data type, then further errors will be issued either by LotusScript or COM/Active-X error reporting. The Notes developer help file for 'CreateObject' gives a bit more detail about unsupported data types:
LotusScript does not support identifying arguments for OLE methods or properties by name rather than by the order in which they appear, nor does LotusScript support using an OLE name by itself (without an explicit property) to identify a default property.
Results are unspecified for arguments to OLE methods and properties of type boolean, byte, and date that are passed by reference. LotusScript does not support these data types.
Relying on the 'default property' to access a default method is a common mistake and requires you to pay extra attention to the component details. It is easy to assume the component is not working, but in fact you're just not using it properly.
One way to test this is to try to open a common object available on all Windows machines (maybe others?) maybe 'FileSystemObject' (FSO) or VbScript 'regExp' component. If these work, you can build on that. Getting the 32/64bit registration correct for your client install is another element to test/get right.
For my issues, I suspect that I was using unsupported methods or data types and having used COM/Active-X in Notes occasionally, its all worked ok in general.

How to set ScriptingContext Response cookie after upgrade to .Net

We have a number of classic ASP websites using a VB6 DLL (COM) object for their functionality in the standard way. The DLL is regsvr32'd and the pages use Server.CreateObject to create an instance of the necessary object in the DLL, which in turn triggers the OnStartPage function of the object being created, passing in the ScriptingContext which we then use to get Request (querystring, form) information, read/update session information and read/write cookie information (etc). For clarification, the way you update/store a cookie value using ScriptingContext is
objSC.Response.Cookies(Key) = Value
In preperation of doing a complete .Net overhaul on the code base (and as a first step), we ran the code through the .Net 2008 VB upgrade tool, which makes a few minor code changes, sets up references to interop libraries (for ADODB, ASPTypeLibrary, CDO, etc) and adds the necessary attributes to allow the .Net object to be exposed to COM, and after a few tweaks here and there guided by comments (todos) left by the upgrade tool, the code is compilable except for anything that tried to update/store a cookie using the above code as now, through the ASPTypeLibrary (Interop), the Response.Cookies collection is readonly (with no obvious way to write a cookie now).
If I comment out the offending line of code, the code compiles, and all I need to do is register this new .Net DLL (and it's interop DLLs) in the GAC, use regasm to register it through COM and the classic ASP sites continue working as if nothing happened (except for writing cookies), using Server.CreateObject to create what it thinks is a COM object, triggering the call to OnStartPage, passing in the ScriptingContext.
So although the code base is "upgraded" to .Net it is using a lot of interop libraries to continues working as before, including using the ASPTypeLibrary.ScriptingContext object, as this is what the classic ASP pipeline exposes.
Does anyone know how to write/store a cookie in this scenario?
Need to convert cookie item to IWriteCookie interface. Then it will be writable.
Imports ASPTypeLibrary
Public Class Test
Private oContext As ASPTypeLibrary.ScriptingContext
Private oResponse As ASPTypeLibrary.Response
Public Sub OnStartPage(e As ScriptingContext)
oContext = e
oResponse = oContext.Response
With CType(oResponse.Cookies("fromdotnet"), IWriteCookie)
.Item = String.Format("hello from .Net : {0}", Date.UtcNow())
'.Domain = ""
'.Path = "/"
'.Secure = False
End With
End Sub
End Class
You may want to check out other interfaces such as IReadCookie, IStringList, IRequestDictionary etc.
With note that:
Full trust for the immediate caller. This member cannot be used by partially trusted code.
there is another option : ContextUtil.GetNamedProperty Method
System.EnterpriseServices.ContextUtil.GetNamedProperty("Response").Cookies("fromdotnet") = "hello"

Classic ASP, Cookies, and VB.NET COM+ objects

This is tangled.
I've been handed a web site written in classic ASP, with a lot of behind the scenes stuff done in VB6 COM+ objects called from the ASP pages via Server.ObjectCreate() instantiations. For this incarnation, the VB6 routines have been converted to VB.NET simply by running the Visual Studio 2003 converter tool on them, and then upgrading that solution file to VS 2008. So there's a thousand and one possible sources for error.
One of the VB6 Modules that is giving me trouble clears a bunch of Response cookies by lines of the following form:
ASPResponse.Cookies("SysUserCode") = ""
Where ASPResponse is defined as :
Private ASPResponse As ASPTypeLibrary.Response
And was set up on Object Activation by:
Set ASPResponse = objContext("Response")
In the VB.NET conversion of this module, those lines became
ASPResponse = ContextUtil.GetNamedProperty("Response")
and
ASPResponse.Cookies("SysUserCode")() = ""
(note the extra pair of parentheses. Not being much of a VB person, I'm not real sure what that syntax means.)
Okay, here's the question: When this code executes on MY machine, that line is giving a VB error 13, with the Error.Description being "Specified cast is not valid." Huh? What cast?
Incidentally, this module runs fine on a co-workers machine, and he cannot see any difference in the configuration of my machine and the relevant components from his.
I'm totally at a loss here. Googling it has given me a bunch of stuff on VB.NET cookies, or COM components with VB.NET, but nothing related to classic ASP cookies.
Is...
Private ASPResponse As ASPTypeLibrary.Response
Set ASPResponse = objContext("Response")
...Post VB.NET conversion? If so, you'll need to explicitly cast objContext("Response") into the ASPTypeLibrary.Response object. This especially applies if Option Strict is on. e.g.
ASPResponse = CType(objContext("Response"), ASPTypeLibary.Response)
Also, Set and Let statements aren't supported in VB.NET.
This MAY have to do with the way the COM component's host is activated. I read another post ([Klaus H. Probst])1 that indicated that, in order to access the Response element, the COM component had to be activated as a Library (as opposed to Server) so that it was running in the ASP process space. So I tried changing the Activation type of the Component's hosting application to library, resetting and rebuilding a few times, and now I'm able to access the Cookies element of the Response. However, my co-worker is still running the host application as a Server, and has no problem.

Tracking COM object error in application

I was using an application and it was working perfect. After some months of not using it, I tried to run it and it doesn't work. It shows a message box saying that it cannot instance a COM object.
Do any know how to track errors in COM objects?
You can use ProcessMonitor and try to find the registry key that may be incorrect.
The other option is to use http://www.moduleanalyzer.com, it intercepts CoCreateInstance showing all created COM objects and the return values.
Run Depends tool on COM object DLL to verify it has all the necessary dlls, re-register the COM dll/exe.
Any HRESULTS from debugging/logs? Any changes in apartment models?
You cannot change the apartment type once you've set one. So if the object cannot use one of the models and you try to CoCreate it, it will fail. That's why you never call CoInit from inside DLL main thread.

Problem when i am accessing ActiveX DLL from VB.NET

Good morning.
I have to access the active x dll which is installed on my system from VB.net.
I added as reference and followed all the steps as given in
I have declared
private mycomponent as activexcomponent.libclass
and i gave constructor for this i.e. creating the object for this class in the constructor of the main form as
mycomponet = new activexcomponent.libclass()
Then the following expection is coming when i tried to run the program.
System.InvalidOperationException: An
error occurred creating the form. See
Exception.InnerException for details.
The error is: Creating an instance of
the COM component with CLSID
{D8A27DFF-A4B8-440E-8571-71A37D39403E}
from the IClassFactory failed due to
the following error: 800a0196. --->
System.Runtime.InteropServices.COMException:
Creating an instance of the COM
component with CLSID
{D8A27DFF-A4B8-440E-8571-71A37D39403E}
from the IClassFactory failed due to
the following error: 800a0196.
I have registered the activex dll. I tried my best to figure out the problem but could not succeed in this.
Please can any one help me out?
Thanks a lot.
As far as I know, that's not a standard HRESULT so you should really read the documentation or contact the developers of the ActiveX control to find out from them what it means. However, I did find comments that for some control it meant that it needs to be shown as modal, so you could try making the form modal (show it using ShowDialog) and see if that makes any difference.