WatiN throws error when using SpecRun - watin

I tried installing SpecRun via Nugget. When I run my features, I obtain the following error:
[ERROR] Get to the Contact Page: The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.
System.Threading.ThreadStateException: The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.
at WatiN.Core.IE.CheckThreadApartmentStateIsSTA()
at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess)
at WatiN.Core.IE..ctor()
Any ideas how to fix this?
Additional Information:
Research
According to http://watin.org/documentation/sta-apartmentstate/, you need to set the Thread.Apartmentstate to STA when using WatiN. However, in order to use a test runner that has not been mentioned in the previous link, you need to email them (email already sent).
My App.config has the following:
<specFlow>
<!-- For additional details on SpecFlow configuration options see https://github.com/techtalk/SpecFlow/wiki/Configuration -->
<unitTestProvider name="SpecRun" runtimeProvider="TechTalk.SpecRun.SpecFlowPlugin.SpecRunRuntimeProvider, TechTalk.SpecRun.SpecFlowPlugin" generatorProvider="TechTalk.SpecRun.SpecFlowPlugin.Generator.SpecRunGeneratorWith, TechTalk.SpecRun.SpecFlowPlugin.Generator" />
<trace traceTimings="false" listener="TechTalk.SpecRun.SpecFlowPlugin.SpecRunListener, TechTalk.SpecRun.SpecFlowPlugin" />
</specFlow>

STA support is now introduced in the new release of SpecRun version 0.14.0
From the release notes:
0.14.0 - 2012/04/20
- Extended beta expiration until 30/05/2012
New features:
...
- Support for STA/MTA apartment state through the execution settings
of the profile: <Execution apartmentState="STA" />
So it should work now with Watin.

Related

Unable to connect to Dynamics CE v.9.0 on-Premises

I have a problem with connecting my .net 4.6.2 console app to our on-Premises Dynamics CE v.9.0 installation.
I have the following code to connect:
CrmServiceClient conn = new CrmServiceClient(connectionString);
OrganizationServiceProxy = conn.OrganizationServiceProxy;
This is my connectionString
<add name="CRM" connectionString="Url=http://ServerFQDN/OrgUniqueName; Domain=Mydomain; Username=MyUser; Password=MyPW; AuthType=AD;"/>
I followed the instructions on the following page to generate the ConnectionString
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/xrm-tooling/use-connection-strings-xrm-tooling-connect
Unfortunately is the OrganizationServiceProxy null all the time.
When i look in my CRMServiceClient i do get the following in LastCrmError
LastCrmError = "Unable to Login to Dynamics CRMOrganizationWebProxyClient is nullOrganizationWebProxyClient is null"
I updated all my NuGet packages to the newest Version:
Microsoft.CrmSdk.CoreAssemblies is 9.0.2.5
Microsoft.CrmSdk.Deployment is 9.0.2.5
Microsoft.CrmSdk.Extensions is 7.1.0.1
Microsoft.CrmSdk.Workflow is 9.0.2.5
Microsoft.CrmSdk.XrmTooling.CoreAssembly is 9.0.2.7
Had anyone had the same Problem?
Do you have a tip for me what could be the Problem?
EDIT
I just noticed, that i am not able to Login via the .NET application but also PluginRegistration and XRMToolBox is not working.
I do assume there is an error with the authentication. Maybe in AD.
When i try to connect i now always get the two following errors:
Microsoft.Xrm.Tooling.Connector.CrmServiceClient
Source : mscorlib
Method : HandleReturnMessage
Error : The caller was not authenticated by the service.
And
Inner Exception Level 1:
Source : System.ServiceModel
Method : ThrowIfNegotiationFault
Error : The request for security token could not be satisfied because authentication failed.
EDIT2
If i login to the Deployment Manager i can see "Failed" in the Status field. I think this is related to each other.
Try to add this line before creating CrmServiceClient object
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
I was able to fix the issue.
The Problem was, that there was some mismatch in between our DB an the Deployment Manager.
The following Steps fixed our Problem:
Delete the Organization in Deployment Manager
Import the Organization again from an existing Organization in Deployment Manager
Configure HTTPS (i think this was not necessary to fix the problem)
Hope this helps others.
PS: Here is a link that describes how you can configure HTTPS:
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/on-premises/post-installation-configuration-guidelines-dynamics-365

Cordova : How to diagnose ajax not working for UWP (windows store) application

I have a simple Cordova application, where when built, and running as a Windows UWP application, has ajax calls are somehow being blocked my work network.
I have asked this many times before, but thought would try to reword, as have never got any solutions.
The application ajax calls work fine on my home machine, or whats seems to be most other networks. When it works, I can see all the output in Wireshark
When on my work machine, connected to our work Network, I see absolutely nothing in Wireshark. If I point to a server running on localhost, the app does work (but I see nothing in Wireshark, but perhaps this is because it is localhost)
If I run the app outside of the UWP container, ie I just run on the same machine, on the same network, but via the desktop browser (as you do for Cordova to debugging), it also works fine.
So it appears to be blocked before it even gets to the Network, as we see nothing in Wireshark at all, so this rules out host not reachable, CORS etc as it hasn't even been sent to the server.
I can run this in debug via Visual Studio, and I run the following test code...
document.addEventListener('deviceready', callUrl, false);
function callUrl() {
console.log('callUrl');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
var DONE = 4; // readyState 4 means the request is done.
var OK = 200; // status 200 is a successful return.
console.log(xhr.readyState);
if (xhr.readyState === DONE) {
if (xhr.status === OK)
console.log(xhr.responseText); // 'This is the returned text.'
} else {
console.log('Error: ' + xhr.status); // An error occurred during the request.
}
}
xhr.open('GET', 'https://httpbin.org/get');
xhr.send(null);
};
onreadystatechangeis called twice, with xhr.readyState first 2 and then 4.
status is always 0.
How can I diagnose what is blocking this?? I have absolutely no idea. This is something low level, but how to see what? I have also looked through Windows Event logs, but can find nothing.
The Ajax call just returns 0 with a blank description. Our Network administrator just says there is something wrong with my app (I have tried multiple Cordova apps, including just basic test apps)
Thanks in advance for any help.
[EDIT1]
In response to the comment from #Xavier, all I have in my AppxManifest.xml (that I extracted from my built .appxupload file) is
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
There is some documentation on the capabilities here, where we have the following (right at the bottom of the page)..
The following capabilities are unavailable when deploying your Remote Mode application to the Windows Store:
Enterprise Authentication (enterpriseAuthentication)
Shared User Certificates (sharedUserCertificates)
Documents Library (documentsLibrary)
Music Library (musicLibrary)
Pictures Library (picturesLibrary)
Videos Library (videosLibrary)
Removable Storage (removableStorage)
Internet client/server (internetClientServer) - note that internetClient is still permitted
Private network client/server (privateNetworkClientServer)
I am not sure were we even set these in Visual Studio (config.xml), but also the above seems to be saying some of these can't be used?
Should the internetClient be enough (I only want to call out to a server as a client, not act as a server).
Also, this seems to be enough to work on most Networks except for my Work..
[EDIT2]
In response to the reply on the CSP...
There is a discussion on this here. The test Cordova app I created in Visual Studio does have this :
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
Surprisingly, I don't see this in my Ionic index.html, but perhaps this is because it is using the white list plugin?
My Ionic application has the following in the config.xml
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="http://localhost:8080/*" />
....
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
It would be great if the ajax even had some error saying it was something to do with CSP if that is what it is, but we just get nothing.
Once again, it is weird that the problem only occurs on my work network (either on cable or our WIFI). If I run the exact machine (e.g. a Surface tablet)over another connection (e.g. tether it to my phones cell), then all works as expected. So it must be some setting to do with the network (or firewall maybe), which also I find strange as surely I would at least then see something in Wireshark.
Would be great to be able to "debug into" the ajax call, and see where it is failing.
[EDIT 3]
After reading one of the comments, I used fiddler to see if I could see anything, which I do...
It even reports 200 (which is not correct), my request still fails.
According to this, you need to request the privateNetworkClientServer capability in order to communicate with a local network.
Note that this capability only works if you app is configured for local mode (your app will be rejected from the store if using this capability in remote mode).
To enable local mode, you need to set <preference name="WindowsDefaultUriPrefix" value="ms-appx://" /> in your cordova config.xml.
Note that local mode might lead to other issues, as you cannot use e.g. inline scripts in local mode (CSP violation)

How do I setup Thinktecture Identity server v3 beta 1-2 with ASP.NET Identity?

I have looked at all the docs for Thinktecture Identity server v3 and have not been able to figure out how to get started using ASP.NET identity.
Can someone please explain at a high level step by step from step 1 (i.e. cloning the git repo) to it's final state which is up and running with the Identity Manager as well. Essentially I just need to know how to set this up.
The videos I see on Vimeo seem out of date (and I may be wrong because I am new to this) because now there are several repositories and in the videos I think I saw the asp.net identity user service in the same solution in core.
I am trying to prototype this for my employer (AngularJS, Identity Server, OAuth 2.0, resource owner vs implicit flow, ) and am hoping to get this working as soon as possible.
Many thanks in advance!
Andrew
Have you checked Thinktecture.IdentityManager.AspNetIdentity solution? There is example how to configure it (see Host project):
public void Configuration(IAppBuilder app)
{
var factory = new Thinktecture.IdentityManager.Host.AspNetIdentityIdentityManagerFactory("AspId");
app.UseIdentityManager(new IdentityManagerConfiguration()
{
IdentityManagerFactory = factory.Create
});
}
In order to add this functionality to the clean project you just have to add necessary packages
<package id="Thinktecture.IdentityServer.v3" version="1.0.0-beta1" targetFramework="net45" />
<package id="Thinktecture.IdentityServer.v3.AspNetIdentity" version="1.0.0-beta1" targetFramework="net45" />
and configure it in the Startup. It's not necessary to clone git repo and compile it...

Sharepoint Designer says: "The list of workflow actions on the server references an assembly that does not exist"

I successfully deploy my custom Action to the list of Actions available for use in my SharePoint Designer, but when opening an existing workflow, or creating a new one in the Designer, I get the message (and of course my custom action is not on the list of actions)
The list of workflow actions on the server references an assembly that
does not exist. Some actions will not be available. The assembly
strong name is {Actual Assembly strong name}. Contact your server
administrator for more information.
I checked the Strong Assembly name, Global Assembly Cache, package options, .ACTIONS file, web.config... Everything seems ok. Any new Ideas?
I am assuming the custom action is a farm deployed activity, which inherits from System.Workflow.ComponentModel.Activity (perhaps using subclass SequenceActivity, but really that doesn't matter)
I'm guessing that you haven't created the required ACTIONS file, which gets deployed to TEMPLATE\1033\Workflow
<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
<Actions Sequential="then" Parallel="and">
<Action Name="Description for SP Designer"
Assembly="$SharePoint.Project.AssemblyFullName$"
ClassName="AssemblyName.ClassName"
AppliesTo="all"
Category="SPD category"
UsesCurrentItem="true"
>
<RuleDesigner Sentence="Line as it appears in SPD workflow" />
<Parameters>
<Parameter Name="__ActivationProperties" Type="Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties, Microsoft.SharePoint" Direction="In" />
</Parameters>
</Action>
</Actions>
</WorkflowInfo>
SPD reads the list of activities from the ACTIONS files. Adding the file will get it into the menu. To actually add it to the workflow, you also need to authorize the custom workflow activity by class name.
To add the authorized type, I use a feature receiver with the following spwebmodification:
private SPWebConfigModification CreateWebConfigModification(string assembly, string assemblyNamespace)
{
return new SPWebConfigModification()
{
Type = (SPWebConfigModification.SPWebConfigModificationType)0,
Name = String.Format("authorizedType[#Assembly='{0}'][#Namespace='{1}'][#TypeName='*'][#Authorized='True']", (object)assembly, (object)assemblyNamespace),
Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes",
Owner = assemblyNamespace,
Sequence = 0U,
Value = String.Format("<authorizedType Assembly='{0}' Namespace='{1}' TypeName='*' Authorized='True' />", (object)assembly, (object)assemblyNamespace)
};
}
this will generate an SPWebConfigModification which can be used during install/uninstall.
Check you local admin privleges. This error comes up if you don't have local priveleges
create a new web and site collection and create a new a new workflow for the new site. you'll get the error message. don't save the work flow. and close the SPD.
reopen the designer and create a new work flow it'll solve the problem.

Update a CRM 2011 record using LINQ example

Can someone please post a confirmed example using linq to retrieve and update a record in CRM Dynamics 2011.
Microsoft claims this is "unsupported" but I have a suspicion it is possible.
I use the "early bound" approach where you generate C# entity classes using the CrmSvcUtil.exe tool, but make sure you use the /codecustomization switch that you'll find in various examples. You'll need the latest version of the CRM 2011 SDK, and must run CrmSvcUtil.exe from the \bin folder of that (don't use the version that installs with CRM).
Your project will need to reference Microsoft.Xrm.Client, Microsoft.Xrm.Sdk and Microsoft.Crm.Sdk.Proxy plus a few others from the .Net framework (look at the build errors to see what you're missing, then add them until it builds).
Here is a basic code snippet that retrieves a Contact entity, updates one of its fields, then saves it back to CRM:
CrmDataContext dc = new CrmDataContext("Xrm");
Contact contact = (from c in dc.ContactSet
where ...whatever...
select c).FirstOrDefault();
contact.FirstName = "Jo";
dc.SaveChanges();
(Note that CrmDataContext is the name of my data context. You can set this name using one of the CrmSvcUtil command line switches).
You'll also need to add a few things to your web.config:
<configSections>
<section name="microsoft.xrm.client" type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client" />
</configSections>
<connectionStrings>
<add name="Xrm" connectionString="Server=http://<your crm url>; Domain=<your domain>; Username=<a crm user id>; Password=<their password>" />
</connectionStrings>
<microsoft.xrm.client>
<contexts>
<add name="Xrm" type="" />
</contexts>
</microsoft.xrm.client>
This is assuming you are running CRM on your corporate network, so the account and domain specified in the connection string would be an AD account, who is set up as a CRM user with relevant permissions to retrieve and update entities.
This is a rough example of using the ODATA provider connected to the online provider
var serverConfig = GetServerConfig(sessionKey);
// Connect to the Organization service.
// The using statement ensures that the service proxy will be properly disposed.
using (var serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials))
{
// This statement is required to enable early-bound type support.
serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
using (var orgContext = new CrmServiceContext(serviceProxy))
{
return orgContext.AccountSet.Where(item => item.Id == id).Select().Single();
}
}
there's also a good example in the SDK:
CRM2011Sdk\sdk\samplecode\cs\wsdlbasedproxies\online

Resources