WatiN permissions problem when eval javascript code - watin

My environment is: WindowXP, IE8, VS2008, WatiN-2.0.20
When i try to execute the follow code:
IE _browser = new IE();
_browser.GoTo(_url);
_browser.Eval("alert('hello!');");
I get the following error:
Message:
"Access denied. (Exception of HRESULT: 0x80070005 (E_ACCESSDENIED))"
Source:
"Microsoft.mshtml"
Partial StackTrace
in WatiN.Core.Native.InternetExplorer.IEUtils.RunScript(String scriptCode, String language, IHTMLWindow2 window)
in WatiN.Core.Native.InternetExplorer.IEDocument.RunScript(String scriptCode, String language)
in WatiN.Core.Document.RunScript(String scriptCode, String language)
in WatiN.Core.Document.RunScript(String javaScriptCode)
in WatiN.Core.Document.Eval(String javaScriptCode)
I know is about a premissions problem but i don't know how solve it.
Any ideas about this issue.

Try turning off IE's protected mode or add your site to trusted zone.

Related

Exception thrown: 'System.UnauthorizedAccessException' in HP.HPRM.OfficeIntegration.Outlook.dll Additional information:

I have written an OutllokAddin.In my email I have attached one draft email. When I open the email and try to open the attach draft email I got the below error.
Exception thrown:
'System.UnauthorizedAccessException' in
HP.HPRM.OfficeIntegration.Outlook.dll Additional information: The
property
"http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/CheckInInfoID"
does not support this operation.
below is my code where SetProperty is throwing error.
Interop.PropertyAccessor propertyAccessor = null;
try
{
propertyAccessor = this.GetPropertyAccessor();
propertyAccessor.SetProperty(propString, value);
}
I have faced this in office 2016. I believe same is also replicate in office 2019.
When I create a new email I don't see the error. Only if I open the attachment I get the error.

Error when creating new RDOSession using RedemptionLoader

Below is my code:
RDOSession pstSession = null;
string binPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
RedemptionLoader.DllLocation64Bit = Path.Combine(binPath, "Redemption64.dll");
RedemptionLoader.DllLocation32Bit = Path.Combine(binPath, "Redemption.dll");
pstSession = RedemptionLoader.new_RDOSession();
Error logged is:
System.Runtime.InteropServices.COMException (0x8004010F): Creating an instance of the COM component with CLSID {29AB7A12-B531-450E-8F7A-EA94C2F3C05F} from the IClassFactory failed due to the following error: 8004010f Exception from HRESULT: 0x8004010F.
Searched the error code but could not get much information. What might be the problem? The issue is not replicated in every machine.
0x8004010F is MAPI_E_NOT_FOUND, which most likely means Redemption cannot find the MAPI system, either because it is not present (Outlook must be installed) or it has a wrong bitness. See http://www.dimastr.com/redemption/faq.htm#ErrorCreatingRedemptionObject for more details.

MSXML2.XMLHTTP , Method 'open' of object 'IServerXMLHTTPRequest2' failed

Dim objHTTPRequest As MSXML2.XMLHTTP
Set objHTTPRequest = New MSXML2.XMLHTTP
With objHTTPRequest
.Open MethodName, strRequest, Asynchronous, strUserName, mstrPassword
'___________more code here___________
End with
I am trying to create a serverConnection object by getting the input parameters from the user using a visual basic form. When run the code, I am getting the following error when executing the above code part. I am working on a word add-in and this error is only occurring when I run the code through vb and the created .dll for the product is working properly with Word.
The following error occurred while submitting this request to a server: Method 'open' of object 'IServerXMLHTTPRequest2' failed
The server address() may be incorrect
in here,
strRequest= "/api/a1/Properties"
If anybody could, Please tell me why is this happening. Because of that error, I am unable to debug the code for further modifications.

PROBLEM :An error message cannot be displayed because an optional resource assembly containing it cannot be found

I created Windows Mobile Application and I loaded web service that contain one method (GetNumber). When I call this method from my emulator I got a following exception
An error message cannot be displayed because an optional resource assembly containing it cannot be found.
Can anyone help me. This is my code from WM Application, it is very siple.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MobileClientApp;
namespace MobileClientApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MobileClientApp.localhost.WebService m = new MobileClientApp.localhost.WebService();
int result;
bool resbool;
m.GetNumber(10, true, out result, out resbool);
label1.Text = result.ToString();
}
}
}
For a very good explanation:
http://blogs.msdn.com/b/netcfteam/archive/2004/08/06/210232.aspx
(excerpt from above)
There has been some confusion about the error message: "Could not find resource assembly". Basically, this means that there is some exception that has happened in the program. The error did not happen because it could not find the resource assembly. The resource assembly that it is searching for contains exception messages (strings) that would be helpful in debugging what went wrong with the program.
Since the user is never expected to see this error message if the program works as expected and all exceptions are handled appropriately, it was decided (due to size constraints) that the resource assembly that has these error strings are never put on a user's device. Thus the main target audience of these error strings are developers who would like to debug issues. Hence, when you do an F5 deploy onto the device, the System.SR.dll assembly which have these error strings are copied to the device and the developer can see the error messages. But in case .Net Compact Framework is installed from a redistributable or you are using .Net Compact Framework that come with the device (as a user of the device would be doing), the System.SR.dll is not present on the device. Hence, if the application did come upon an exceptional condition that wasn't handled by the application, this "Could not find resource assembly" message would be shown to the user.
If you are not using Visual Studio F5 deploy to the device and would still like to see the exception messages, you can achieve this by taking the System_SR_[Language].CAB where [Language] corresponds to the language in which you want to see the error message to appear and clicking on the cab file to install it
Sounds like you are missing an assembly in your deployment.

Access denied error ( Visual Studio and WatiN )

I'm using the WatiN testing tool with Visual Studio 2005. When I try to select a value from my list box I am getting an "access denied" error.
I have seen this a lot with select lists recently when using the WatiN 2.0 beta. Instead of using the aSelectList.Select(strText) option, it seems to work better when you do this:
ie.SelectList(Find.ById("MySelect")).Option(Find.ByText("Option 1")).Select();
This can also happen when changing an ASP.NET control that cause an auto-postback. The first change will register, but the next element you try to access will throw an "Access Denied" error because it is still trying to access the old page. In this case you can try using ie.WaitForComplete(), but sometimes this is required:
ie.SelectList(Find.ById("AutoPostBackSelect")).Option(Find.ByText("Option")).Select();
System.Threading.Thread.Sleep(200); //Sleep to make sure post back registers
ie.WaitForComplete();
ie.SelectList(Find.ById("MySelect")).Refresh()
ie.SelectList(Find.ById("MySelect")).Option(Find.ByText("Option 1")).Select();
This is a bug in the select list where if the list is not ready to accept input, and it can throw one several exception types. We solve it like this:
try
{
_domContainer.SelectList(_control.WatinAttribute).Focus();
_domContainer.SelectList(_control.WatinAttribute).Select(value);
}
catch (Exception e)
{
Console.WriteLine("Select list eception caught: " + e.Message + e.StackTrace);
// we have tried once already and failed, so let's wait for half a second
System.Threading.Thread.Sleep(500);
_domContainer.SelectList(_control.WatinAttribute).Select(value);
}
And yes I know that swallowing all exceptions like this is normally bad, but if the exception occurs again, it is thrown to the test code and the test fails.
I noticed this happens if you try and select a value that is already selected.
You can work around this with a pre-check:
if(_sel_ddlPeriodFromDay.GetValue("value")!="1")
_sel_ddlPeriodFromDay.SelectByValue("1");
or maybe use a try catch?
try{_sel_ddlPeriodFromDay.SelectByValue("1");}
catch{}

Resources