Azure Web App and Azure SQL connectionString error - azure

I have taken the Connection String from my Azure SQL instance via the portal and pasted it into my web.config. If I test the connection string when I create the Publishing Profile it is fine. If I throw an exception in Global.asax to see my connection string like this:
throw new Exception(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
, it shows my correct one. However, I still get this error:
{
"Message": "An error has occurred.",
"ExceptionMessage": "Format of the initialization string does not conform to specification starting at index 0.",
"ExceptionType": "System.ArgumentException",
"StackTrace": " at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)\r\n at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)\r\n at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)\r\n at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)\r\n at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)\r\n at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)\r\n at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)\r\n at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)\r\n at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<SetConnectionString>b__18(DbConnection t, DbConnectionPropertyInterceptionContext`1 c)\r\n at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection, DbConnectionPropertyInterceptionContext`1 interceptionContext)\r\n at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)\r\n at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)\r\n at System.Data.Entity.Internal.LazyInternalConnection.Initialize()\r\n at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()\r\n at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()\r\n at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context)\r\n at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()\r\n at System.Data.Entity.Internal.InternalContext.Initialize()\r\n at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)\r\n at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()\r\n at System.Data.Entity.Internal.Linq.InternalSet`1.Include(String path)\r\n at System.Data.Entity.Infrastructure.DbQuery`1.Include(String path)\r\n at ExpressoApi.Controllers.MenusController.GetMenus() in C:\\Users\\david\\Desktop\\ExpressoApi-master\\ExpressoApi\\Controllers\\MenusController.cs:line 17\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__3(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
}
I've spent a couple of hours trying to fix this, I've made no progress.

I found the problem. Simply pasting the connection string into my web.config of my Azure App does nothing. I needed to add the connection string into my PUBLISHSETTINGS file and the re-publish. Then everything works.

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!

Providing Coded-UI support for VS2012,2013,2015

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

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]

Server Error: Problem Loading webpart

I am trying to add OneViewCalendarWebpart to my site. I am getting the following error when I try to add the webpart from the gallery.
Server Error in '/' Application.
Value cannot be null.
Parameter name: g
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: g
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Value cannot be null.
Parameter name: g]
System.Guid..ctor(String g) +7452814
Microsoft.GroupBoard.WebControls.CalendarViewControlTraverser.GetListFromCalendarControl() +62
Microsoft.GroupBoard.WebControls.CalendarViewControlTraverser.get_IsSRList() +8
Microsoft.GroupBoard.WebControls.GbwListDeterminer.OnInit(EventArgs e) +83
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
System.Web.UI.ControlCollection.Add(Control child) +80
Microsoft.SharePoint.WebControls.SPCalendarView.CreateChildControls() +644
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +44
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.WebControls.WebParts.WebPart.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
It seems like the ListName property is not initialized, but the webpart tries to read it (as far as I understand, you are having a problem with Microsoft GroupBoard Workspace webpart).
As far as I can recall from the time I played with the "GroupBoard" solution, these webparts have to be added from code and cannot be added from Webpart gallery. Take a look at the comments in this blog post: http://www.spelements.com/blog/2009/01/printing-sharepoint-lists-calendars/

Resources