WatiN on AppHarbor: COMException, "Server execution failed" - watin

I'm using WatiN in a console application. I set platform to x86, and I added [STAThread] to my Main. I confirmed that the application is actually running in 32-bit mode (which WatiN requires).
WatiN works fine when testing locally, but crashes when running on AppHarbor:
[COMException: Retrieving the COM class factory for component with CLSID {0002DF01-0000-0000-C000-000000000046} failed due to the
following error: 80080005 Server execution failed (Exception from
HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).]
0007FFB8B2184B3 WatiN_Core!WatiN.Core.IE.CreateNewIEAndGoToUri(System.Uri,
WatiN.Core.Interfaces.IDialogHandler, Boolean)+0x103
How can I get WatiN working on AppHarbor?

To be able to run WatIn it need to have access (as an administrator) to some resources. When you run a COM object it needs to be able to query the registry to find out if Internet Explorer is a COM object in that system and if it is launch it. I don't have first hand experience with AppHarbor but I'm pretty sure they won't allow you to be able to query what COM servers their machines have so they won't provide you with that access.
To be 100% sure about this you should ask them if you can have access to query COM objects on their machines.
When you run it on your local machine that works because either you are logged in as an admin or you are launching the process as an admin.
Hope this helps.

Related

Creating service-based COM instance from CLSID

Windows Subsystem For Linux (new techonology in Win10) uses LxssUserSession service. This service is undocumented, but it is used as API for WSL (bash.exe uses this service to run ELFs). As i can see, it is part of COM: There is CLSID record in registry that has AppID. And AppID has LocalService record: LxssUserSession.
I am not familiar with COM, but if I understand it correctly, there should be COM component backed by this service. I am not able to create instance of this COM from script since there is no ProgID, but I tried to instantiate it using OleView. How ever, it reports that CoCreateInstance returned error. How to debug this error? Could it be that COM component can't be created and used for something different (i.e. there is some other interface). Is it generally possible to work with undocumented COM component? Can I trace bash.exe calls to this service (something like logger.exe or ltrace but for COM?)
Some background:
Here is error I am getting: http://s32.postimg.org/wpthro5kl/error.png
bash.exe != /bin/bash. bash.exe is PE (Win64 bin app) that connects to LxssUserSession and asks it to run /bin/bash (which is ELF (linux app!). bash.exe is better be called "WLS.exe", but for some reason they called it bash.exe.
Please see here: https://msdnshared.blob.core.windows.net/media/2016/04/LXSS-diagram-1024x472.jpg and here is its headers http://s32.postimg.org/khjjf81th/bash.png .
So, I am sure bash.exe uses COM to connect to LxssUserSession and LxssUserSession uses Pico (Psp..) functions to launch ELF as "pico process" (See here https://blogs.msdn.microsoft.com/wsl/2016/04/22/windows-subsystem-for-linux-overview/).
Both are undocumented, but I believe I can use COM some how, but I am getting error which I provided as first link:(
I was able to instantiate object using OleView by setting default impersonation level to "Impersonate" in component services config (you may need to reboot). I can see ILxssSession interface now. But since there is not IDispatch and no TLB, there is nothing I can do: methods are unknown to me(
I just doing the same kind of project. What I do is reverse engineering "bash.exe" to see how it work. Currently, I can create an insurance of LxssUserSession and call some method in it. But it still not complete. You can find it source here.

Getting exception when accessing outlook through Redemption COM

We are accessing outlook through redemption DLL in c#.net. We are using various services like: importing contacts, calendar integration etc. Sometime we are getting exception from redemption COM like:
The file abc.ost is in use and cannot be accessed.
'MyApplication' exited without properly closing your Outlook data file
Could somebody help us to identify the root cause of this issue?
Exception details are mentioned below:
Exception1:
OutlookServices.OutlookService -
System.Runtime.InteropServices.COMException (0x80040119): Error in
IMAPISession.OpenEntry: MAPI_E_EXTENDED_ERROR
Error: 'MyApplication' exited without properly closing your Outlook
data file
'C:\Users\abc\AppData\Local\Microsoft\Outlook\abc#org.com.ost'.
'MyApplication' must be restarted. If this error message recurs,
contact support for 'MyApplication' for assistance.
at Interop.Redemption.IRDOSession.GetMessageFromID(String
EntryIDMessage, Object EntryIDStore, Object Flags)
Exception2:
OutlookService - System.Runtime.InteropServices.COMException
(0x8004011D): Error in IMAPISession::OpenMsgStore:
MAPI_E_FAILONEPROVIDER
Error: The file
C:\Users\abc\AppData\Local\Microsoft\Outlook\abc#sigmacare.com -
abc.ost is in use and cannot be accessed. Close any application that
is using this file, and then try again. You might need to restart your
computer.
at Interop.Redemption.IRDOSession.GetDefaultFolder(rdoDefaultFolders
FolderType)
Are you sure your application was terminated gracefully? Do you release Redemption objects as soon as you are done with them?
Are both your app and Outlook running in the same security context? Is either app running with elevated privileges (Run As Administrator)? Normally, OST files can be shared between different processes (e.g. outlook and your process) as long as the security contexts are the same.

Could not obtain information about Windows NT group / user, error code 0x3a

I am trying to deploy a SQLCLR library to SQL Server 2008 R2. In visual studio I have set up the data connection and it works correctly (I can run queries), but when I try to deploy I get the message "Error: Could not obtain information about Windows NT group / user , error code 0x3a."
This is strange because I have set up the data connection to use SQL server authentication on a different user name.
I receive the same error when I run CREATE ASSEMBLY while logged in to the SQL management studio with the different user name.
To add to the mystery, when I deploy using permission set SAFE everything is fine. However my assembly requires EXTERNAL ACCESS.
What could be the problem with deploying my assembly?
This issue wasted so much time I feel compelled to share the solution so that nobody else falls into the same trap.
Issue was resolved by setting the SQL Server Active Directory Helper service to run on Manual, then rebooting the server.
This issue arose in a different environment for me:
Windows 10 box;
The user Windows complained about was an AZUREAD user;
On my Win10 box there was no SQL Server Active Directory
Helper service, so I couldn't try the original solution posted by
ose.
I was able to work round the issue by removing the AZUREAD user as a SQL Server user while I added the assembly.
In my case that user was not essential to have as a SQL Server user, but I dare say it would be possible to re-add the user back later should this be required.

WMIPRVSE needs to be run under network services by default

I have 2 separate servers (windows server 2008 r2) from where I am running vbs scripts through a microsoft scheduler ( my-computer>manager>Schedule). when I run vbs scripts locally they are working fine, but when it is being run through scheduler one of servers is getting stacked. while the other is working fine. And also I have noticed from task manager that the working server runs the WMIPRVSE.exe though Network Service user and the other one shows SERVICES as user.
How to make sure that WMIPRVSE.exe will always run under Network Services. Thanks
Edit:
I have tried to change the log on user from services, but it failed to start the service than.
There are a few things I have tried, but I don't know which one helped me.
What I did is I granted all permissions to wscript file which is located in system32 somewhere, and after some time it became Network Servies. Again not really sure whether it was because of that change or other thing.

Printing from an application in IIS to a networked printer on server

I have a line of code that I can run locally as part of a service that works perfectly fine.
sReportPath = objCrystalUtils.ExportReportToPDF("Report Name", iReportInfoID)
This code is run as a part of a service, and when I unit test it by feeding it data, it ultimately builds the report and prints it.
When I run the exact same piece of code inside an .ashx from an ajax call. The reports are generated (I can see the pdf files being created on disk) but the printing is not happening.
oRpt.PrintToPrinter(objReport.DefaultAutoPrint, True, 0, 0)
In both scenarios the same code is used to print the report. (objReport.DefaultAutoPrint = 0 in both cases)
My only thought is that the location of the code that is calling this method is in a different spot relative to the location of the bills themselves.
The printer that I'm trying to print to is a network printer intalled on my machine, and I'm running Windows 7 IIS 6.1
Any thoughts?
Edit:
Here is a thought... if I'm running one as a unit test locally and im running the other through a web app that is running via IIS, is there a difference in user id and user access to the default printer?
Edit:
So I added my local ASP, IUSR and SYSTEM users to the printer security and allowed them to print... no dice. So I checked the EVERYONE user and it is set to access and NO users are denied... so I think that kinda kills that line of reasoning.
Edit:
I changed the name of this post since I no longer think that the issue is ajax related since If I try to do the same process in code bebehind from a post back instead of running it from an ajax call i still get the same problem.
Patrick, for me it is a known issue of crystal reports, printing a certain report from a running application via IIS.
I got the same issue before, and upon our search for that issue, we got the following;
Report to be generated, exported, and then to be downloaded to client machine,
so user can print it locally (say, report will be exported as PDf file,
user can use print option of PDF reader).
It's not Crystal Reports or other third party app's problem. It's usually the IIS_IUSER's permission problem because it has no access to any network printers. A possible solution is in Process.Start doesn't work in IIS

Resources