I have an asp.net 4.0 project that uses a combination of Bouncy Castle and the .Net framework to create an X509 certificate.
It runs properly on my W7 dev machine but when installed on W2008 (32 bit, not r2) this bit of code:
CX509CertificateRequestPkcs10 csr = new CX509CertificateRequestPkcs10();
throws this exception:
Unable to cast COM object of type 'System.__ComObject' to interface type 'CERTENROLLLib.CX509CertificateRequestPkcs10'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{728AB35B-217D-11DA-B2A4-000E7BBB2B09}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Initially I thought it might be a 64-bit server issue since COM is only 32-bit compatible but the server is 32 bit.
The app is built using Framework 4.0 and the IIS AppPool assigned is running 4.0, Integrated mode, with an Identity of "Network Service" - all exactly as on my dev machine, as the the client browser used (IE8 32).
Does W2008-32 (Standard) not implement CERTENROLLLib out of the box? Does anyone know how to make it behave in this circumstance?
Thanks for any suggestions!
When you instantiate CX509CertificateRequestPkcs10 object specify explicitly what interface you want to use (by ProgID). In Win2008 R2 Microsoft overwrote the interface.
Instead of:
CX509CertificateRequestPkcs10 objPkcs10 = new CX509CertificateRequestPkcs10();
use:
IX509CertificateRequestPkcs10 objPkcs10 = (IX509CertificateRequestPkcs10)Activator.CreateInstance(Type.GetTypeFromProgID("X509Enrollment.CX509CertificateRequestPkcs10"));
Since in Win2008 R2 Microsoft overwrote the interface, if the code is written in Win2008 R2 the run time is looking for the new interface GUID and in regular Win2008 it can't be found because Win2008 R2 interface GUID differs from Win2008 interface Guid.
So, object can't be created, and as the result exception is thrown.
Accessing the interface by ProgID solves the issue.
See: TechNet Answer - on W2008-32 one has to specify the Interface GUID when creating the Pkcs10 object, since R2 overwrote the old "standard" interfaces.
Related
Can anybody tell how to debug the Com Dll in IIS 7.0 using VB 6.0 in Windows Server 2008 R2.
I am able to hit break point in VB 6.0 accessed from Console Application using interop dlll.Through ASPX pages in IIS 7.0 I am getting the following Exception
Unable to cast COM object of type 'XCreateUser.XAcctUserProfileClass'
to interface type 'XCreateUser._XAcctUserProfile'. This operation
failed because the QueryInterface call on the COM component for the
interface with IID '{7A48FABA-CCC8-4FA6-94E8-803F6CF121F2}' failed due
to the following error: Error loading type library/DLL. (Exception
from HRESULT: 0x80029C4A
Already DLL built and registered and com interop dll generated.
Please somebody show some light on this
Already DLL built and registered
"Registered" is the problem here, it wasn't correctly registered. This is an exception message that's generated by the CLR when it tries to locate the proxy for a .NET component that is [ComVisible]. A proxy is required to make a call to a COM component from a worker thread that doesn't do anything to help make the call thread-safe. A thread that's in the MTA, usually a thread-pool thread.
A .NET component is registered with Regasm.exe. You forgot to use the /tlb argument.
Should be simple to fix. If you still have trouble then SysInternals' Process Monitor is the weapon of choice.
I generally debug these things as you say through a console or windows forms application. You can always add logging to your web app to see what parameters are being passed to it.
Generally errors like the above are setup issues when running on a 64 bit platform and when utilizing 32 bit dlls. One thing to make sure of is that your application pool allows 32 bit applications. In IIS Manager right click on the application pool your website is running under and go to Advanced Settings->Enable 32 bit Applications. Set that to True.
You'll also need to make sure that your 32 bit dll is registered in the 32 bit registry hive. C:\Windows\syswow64\regsvr32 is the version you'll need to use to register this dll.
we're migrating certain COM+ components from VB6.0 to C#.Net. I'm facing some challenges regarding the conversion of code (rewriting), one thing is this particular COM+ component will be consumed by multiple classic asp applications, these applications either pass ADODB Recordset as input parameter and also accept it as an output parameter. after developing a piece of code and testing it locally on 32 bit machine I'm able to build the connectionstring and also pass and accept Recordset. but when I migrate to code to windows 2012 R2 64 bit server. I see error when I try to create the object of the DLL.
So my question is it possible to use Recordset and expose it through COM+ on 64 bit machine?
I got a new problem while using vb6 dll in my Web Services. When using dll, the object instance is created fine but when I start calling it's method from my service I got this exception:
Server was unable to process request. ---> Unable to cast COM object
of type 'WS_Resevat_DLL.WS_ResevatCLClass' to interface type
'WS_Resevat_DLL._WS_ResevatCL'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{69F1DA59-56D1-47CE-94A4-D681ABECDF80}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
The whole system runs fine when I test it on my computer IIS (I have Windows 7 with IIS 7). The problem starts when I publish it on server (Windows Server 2003 with IIS 6). I'm using asp.net 3.5 web services with SOAP 1.1. The VB dll is from the third part and I sadly can't debug it (the only thing I checked with dll creator is that binary compatability is enabled, I don't know VB at all), but when it runs outside the service (on Win Server 2003) it works fine.
Some explanation bout the types (WS_ResevatCLClass and WS_ResevatCL). In origin the dll has only one type: WS_ResevatCl. But when I look at the dll in component explorer in Visual Studio I see strange things - there is a class called WS_ReservatCLClass and 4 different interfaces: _WS_ResevatCL, WS_ResevatCL, WS_ResevarCL_v0 and WS ResevatCL_v1. And the most strange thing is that I can create instance of one them (WS_ResevatCL) and it drives exactly like an instance of the class.
Are there any significant differences between Win7 and WinServer2003 that can cause the crash with such exception?
I am basically a .NET guy.I don't have much knowledge in VB (COM components). Now,I come across a project where i need to expose a COM dll as a webservice and consume the same in my Asp.NET application.I hosted the webservice on my local development machine and consumed it in a test application.It works just fine.But When i host it on my production server(Server 2003).
It throws 500 internal sever error.When i looked at the stack trace,came to know that Inoke method is throwing error at the below line.
object[] results = this.Invoke("Addition", new object[] {
parameter1,parameter2});
return ((short)(results[0]));
I have registered (example.dll) using command prompt utility as below
regsvr32 c:\windows\system32\example.dll
So,Can anyone suggest me the cause for the following error?
Thanks in advance,
If you are registering a .NET dll that exposes COM interfaces you should be using REGASM instead of REGSRV32.
May you help me, My ASP.NET application can't import excel file when migrating this application that run in Win Server 2003 32-bit to the Win server 2008 64-bit environment.
How to fix this bug? because in Win Server 2003 32-bit, it runs properly.
the error report that appear is:
*System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad) at Admin_ImportRisk.CreateTempTable() in C:\inetpub\wwwroot\ERMApproval\Administrator\ImportRisk.aspx.vb:line 66.*
The code in line 66 of my application is:
oBooks.Open(Server.MapPath("~/App_Data/Risk.xls"))
I have tried several scenarios:
Added Network Service user to the Microsoft Excel Application in DCOM configuration and set the identity of Application pool that in used to be same.
Added all many kind of user to the Microsoft Excel Application and My computer in security of DCOM configuration. And I have added many kind of user too in the application's folder.
Used corflags.exe to force 32-bit application to run in 64-bit environment
Used regsvr32.exe to register a Microsoft.Office.Interop.Excel.dll file to the windows 32-bit component services.
Used rundll32.exe to run the 32-bit Microsoft.Office.Interop.Excel.dll file in the 32-bit environment
But the result is still the same.
It will be a big honour if you can help me^^.
Best regards,
-imanuel-
The simple answer is to compile your project to target x86 only. This is a setting in the project settings. So the .net framework will only generate a 32 bit application at runtime, rather than defaulting to 64 bit. This is no different from setting corflags, however if you have multiple assemblies you ahve to make sure it's done for all of them. The application itself must target only 32 bit.
You're using a COM component that is 32 bit, and you can't do that in a 64 bit application, so force it to be 32 bit.
You can also force IIS to run it in the 32 bit context as documented here:
http://lostechies.com/gabrielschenker/2009/10/21/force-net-application-to-run-in-32bit-process-on-64bit-os/
Also, make sure the 64 bit version of Excel is not installed on the server, but rather the 32 bit version.