Providing Coded-UI support for VS2012,2013,2015 - visual-studio-2012

I have successfully implemented the Coded UI support for my custom control in VS2010. But when i try to upgrade those projects to VS2012, VS2013, or VS2015, the following exception has occurred. Please find the exception stack trace below:
Sample code:
if (uiTestControl.ControlType == ControlType.Table)
{
//To-Do
}
Exception:
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Invalid cast from 'System.String' to 'Microsoft.VisualStudio.TestTools.UITesting.ControlType'.
Source=mscorlib
StackTrace:
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyInternal[T](String propertyName)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_ControlType()
at CustomControl.GetPropertyNames(UITestControl uiTestControl) in d:\Coded_UI_Source\Src\CustomExtensionProvider\CustomPropertyProvider.cs:line 94
at Microsoft.VisualStudio.TestTools.UITesting.ALUtility.GetProperties(UITestPropertyProvider provider, UITestControl uiControl, UITestPropertyAttributes attributes, UITestPropertyAttributes ignoreAttributes)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetReadableAndAssertablePropertyNames()
at Microsoft.VisualStudio.TestTools.CodedUITest.Controls.UIControlLocator.UIControlFinder.FetchProperties(UITestControl element)
at Microsoft.VisualStudio.TestTools.CodedUITest.Controls.UIControlLocator.UIControlFinder.PopulateUITestControlDetails(UITestControl element, UIControlDetails uiControlDetails)
at Microsoft.VisualStudio.TestTools.CodedUITest.Controls.UIControlLocator.UIControlFinder.CaptureControl(UITestControl element)
at Microsoft.VisualStudio.TestTools.CodedUITest.Controls.UIControlLocator.UIControlFinder.PlaybackThreadproc()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Please help me to overcome this issue and also please let me know whether i need to do anything to support in VS2012, 2013 and 2015.

The problem occours in your code CustomPropertyProvider.cs:line 94, it is calling the get_ControlType() which is looking from control type. It seems you haven't set the control type correctly in the custom control when it tries to convert the name of the controltype into a Type.
at CustomControl.GetPropertyNames(UITestControl uiTestControl) in d:\Coded_UI_Source\Src\CustomExtensionProvider\CustomPropertyProvider.cs:line 94

Related

AdomdConnectionException: The connection string is not valid with pyadomd

I am trying to set up connection to the PowerBI service with the pyadomd library.
Here is the connection string:
"Provider=MSOLAP;Data Source=powerbi://api.powerbi.com/v1.0/myorg/workspace_name;User ID=user_email;Password=user_passw;Initial Catalog=dataset_name"
I get the error:
AdomdConnectionException: The connection string is not valid. ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.GetInstancePort(ConnectionInfo connectionInfo)
--- End of inner exception stack trace ---
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.GetInstancePort(ConnectionInfo connectionInfo)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.GetTcpClient(ConnectionInfo connectionInfo)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenTcpConnection(ConnectionInfo connectionInfo)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Connect(Boolean toIXMLA)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()
Does anyone know what is wrong?
I don't want to use the other library like "adodbapi" in this case as I have another unresolved error with it.

Acumatica Rest API Returning Errors Differently In Code than Postman

This problem has been driving me nuts for hours and I can't figure out what's going on. For example's sake, I have created a test action on a custom page in my Acumatica installation.
This test action is as follows:
public PXAction<UsrPCMJob> testAction;
[PXUIField(DisplayName = "Test")]
[PXButton()]
public virtual void TestAction()
{
throw new PXException("This is just a test action!");
}
I have created a rest endpoint for this page and mapped the test action.
If I create the post in Postman, it works as expected:
{"entity":{"Job":{"value":"0228467"}},"parameters":null}
and I get the following as a response:
"exceptionMessage": "PX.Data.PXException: This is just a test action!
However, in code (PHP, using Guzzle for my request), even though my json body is the same:
{"entity":{"Job":{"value":"0228467"}},"parameters":null}
I get this error message:
{"message":"An error has occurred.","exceptionMessage":"PX.Data.PXException: Error #251: Failed to commit the Job row.\r\n at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()","exceptionType":"PX.Api.ContractBased.OutcomeEntityHasErrorsException","stackTrace":" at System.Monads.ArgumentCheck.CheckNull[TSource](TSource source, Func`1 exceptionSource)\r\n at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, List`1 errors) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 457\r\n at PX.Api.ContractBased.EntityService.Invoke(ISystemContract systemContract, String version, String name, EntityImpl entity, ActionImpl action, CbOperationContext operationContext) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 720\r\n at PX.Api.ContractBased.Soap.EntityGateBase.InvokeImpl(EntityImpl entity, ActionImpl action) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\EntityGateBase.cs:line 144\r\n at PX.Api.ContractBased.Soap.EntityGateV2.PX.Api.ContractBased.IRestGate.Invoke(EntityImpl entity, ActionImpl action) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\EntityGateV2.cs:line 357\r\n at PX.Api.ContractBased.Soap.WebApiSoapController.RestInvoke(EntityEndpoint endpoint, String objectName, String actionName, ActionInvocation invocation) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\WebApiSoapController.cs:line 414\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}
My php guzzle client that I created works fine on other requests that use actions, but not for this test action or a few other actions.
Any help you can offer would be GREATLY appreciated. Thanks!

MethodAccessException when calling nlog LogManager.GetCurrentClassLogger()

I'm getting an exception when I run a unit test on a controller in web project (ASP.NET web api). The exception is thrown when LogManager.GetCurrentClassLogger() of the controller is executed:
System.MethodAccessException: Attempt by method 'Castle.Proxies.ClaimsPrincipalProxy.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' to access method 'Castle.DynamicProxy.Internal.TypeUtil.Sort(System.Reflection.MemberInfo[])' failed
It results in TypeInitializationException in LogManager.GetCurrentClassLogger().
here is the call stack:
at Castle.Proxies.ClaimsPrincipalProxy.GetObjectData(SerializationInfo, StreamingContext)
at System.Runtime.Serialization.ObjectCloneHelper.GetObjectData(Object serObj, String& typeName, String& assemName, String[]& fieldNames, Object[]& fieldValues)
at System.AppDomain.get_Evidence()
at System.AppDomain.get_Evidence()
at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, ref String typeName)
at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, ref Object result, ref Object resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at NLog.Config.XmlLoggingConfiguration.get_AppConfig()
at NLog.LogFactory.get_Configuration()
at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
at NLog.LogFactory.GetLogger(String name)
at NLog.LogManager.GetCurrentClassLogger()
Update:
The issue happens when the unit test project references NSubstitute. So, it seems like there some dangerous combination of Web API, NSubstitute and NLog.
Update 2:
Found what upsets Nlog in Controller.
Before calling controller method I set mocked principal for Thread.CurrentPrincipal:
var principal = Substitute.For<ClaimsPrincipal>();
principal.Identity.Returns(...);
Thread.CurrentPrincipal = principal;
How could this be fixed?
The Castle assembly may be marked with the AllowPartiallyTrustedCallersAttribute, and that uses the level 2 security transparency model.
Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
Can you try annotating your unit test (and Class) with the following attribute - [SecuritySafeCritical]

Team Build Error: Expression of type 'Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings'

I am getting an error as soon as I’m triggering the build.
We are using TFS2012 and VS2012.
Actually I have customized the DefaultTemplate.11.1.xaml to suite project requirement.
And after adding the Custom Activities and Template we are getting an error..
TF215097: An error occurred while initializing a build for build definition \ALM\VersioningBuild: Exception Message: Expression of type 'Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings' cannot be used for return type 'Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings' (type ArgumentException)Exception Stack Trace:
at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression& body, ReadOnlyCollection1 parameters) at System.Linq.Expressions.Expression.LambdaTDelegate at System.Linq.Expressions.Expression.LambdaTDelegate at Microsoft.VisualBasic.Activities.VisualBasicHelper.CompileT at Microsoft.VisualBasic.Activities.VisualBasicHelper.CompileT at Microsoft.VisualBasic.Activities.VisualBasicHelper.CompileT at Microsoft.VisualBasic.Activities.VisualBasicValue1.CacheMetadata(CodeActivityMetadata metadata) at System.Activities.CodeActivity1.OnInternalCacheMetadataExceptResult(Boolean createEmptyBindings) at System.Activities.Activity1.OnInternalCacheMetadata(Boolean createEmptyBindings) at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList1& validationErrors) at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack1& activitiesRemaining, ActivityCallStack parentChain, IList1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback) at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList1& validationErrors) at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList1& validationErrors) at System.Activities.Validation.ActivityValidationServices.InternalActivityValidationServices.InternalValidate() at Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.ValidateWorkflow(Activity activity, ValidationSettings validationSettings) at Microsoft.TeamFoundation.Build.Hosting.BuildProcessCache.LoadFromXaml(String workflowXaml, TextExpressionImports textExpressionImports) at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager.PrepareRequestForBuild(IBuildDetail build, WorkflowRequest request, IDictionary2 dataContext) at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(WorkflowRequest request, WorkflowManagerActivity activity, BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)
I’m totally stuck over here.
Any help would be much appreaciated.Thanks!!
This turn out that i was referring wrong version (Lower Version) of Microsoft.TeamFoundation.Build.Workflow in my project.
but the Build server were having higher vresion of dll.

NHibernate Validator throwing and catching sqillions of MappingExceptions (property not found)

After upgrading from NHibernate 2 to 3.1, NHibernate Validator is throwing and catching tons of MappingExceptions with the message "property not found: myProp on entity MyEntity".
The stack trace is:
at NHibernate.Mapping.PersistentClass.GetProperty(String
propertyName, IEnumerable`1 iter) in
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Mapping\PersistentClass.cs:line
921 at NHibernate.Mapping.PersistentClass.GetProperty(String
propertyName) in
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Mapping\PersistentClass.cs:line
934 at
NHibernate.Validator.Engine.ClassValidator.FindPropertyByName(PersistentClass
associatedClass, String propertyName)
The NHibernate Validator source code for the method FindPropertyByName doesn't look too hot - there's just a large chunk of commented out code.
Is this just because NHibernate Validator is not ready for NHibernate 3, or is there a workaround?

Resources