Getting connection error with local emulator - c#

In my Azure application when I am trying to connect to local emulator, I am getting an error.
The line of code I am getting the error on is:
CloudStorageAccount CSC = CloudStorageAccount.Parse(
RoleEnvironment.GetConfigurationSettingValue("connection"));
In CS Def
<ConfigurationSettings>
<Setting name="connection" />
</ConfigurationSettings>
In .cscfg
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="connection" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
Stack Trace:
at RdGetApplicationConfigurationSetting(UInt16* , UInt16** )
at RoleEnvironmentGetConfigurationSettingValueW(UInt16* pszName, UInt16* pszDest, UInt32 cchDest, UInt32* pcchRequiredDestSize)
at Microsoft.WindowsAzure.ServiceRuntime.Internal.InteropRoleManager.GetConfigurationSetting(String name, String& ret)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName)
at WebRole1._Default.Page_Load(Object sender, EventArgs e) in c:\users\gowdes\documents\visual studio 2010\Projects\WindowsAzureProject20\WebRole1\Default.aspx.cs:line 19
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

this may seem overly simplistic... but double check that the default application is indeed your Cloud Application project and NOT the ASP.NET/Web project. Without the "Cloud" context, you'll definitely get the SHException or something similar.

#Jim O'Neil already pointed out that you need to run with the Cloud project being your startup project to avoid SEHException. I also talk about SEHException in this SO answer.
Looking at your comment above, you said your code hits the else part of:
if (RoleEnvironment.IsAvailable)
That means the role environment (e.g. Windows Azure) is not available and you won't be able to execute:
CloudStorageAccount CSC = CloudStorageAccount.Parse(
RoleEnvironment.GetConfigurationSettingValue("connection"));
This most likely reason is because the Cloud project is not the startup project. Or, possibly the emulator isn't being launched (which happens if you don't run Visual Studio as Administrator).

Related

Same function with same arguments, from same dll reference (same path, same file), working for one .NET project, but not for an other

The .NET project that works is on .NET framework 4.6.1. The one that does not work is on .NET framework 4.7.2.
This is the Function:
return DAL.DALGeneral.SelectScalar("GetYearName", new Dictionary<string, object>() { { "Year", year } }).ToString();
This is the Error message:
[NullReferenceException: Object reference not set to an instance of an object.]
DAL.DALGeneral.GetConnectionString(String DataBase) +83
DAL.DALGeneral.SelectScalar(String spName, Dictionary`2 parameters, String DataBase, String ConnectionString) +123
OnlineYudGimelDaledSignIn.Models.LookUp.GetYearName(Int32 year) in C:\Users\giln\source\repos\OnlineYudGimelDaledSignIn\OnlineYudGimelDaledSignIn\Models\LookUp.cs:58
OnlineYudGimelDaledSignIn.Site.Page_Load(Object sender, EventArgs e) in C:\Users\giln\source\repos\OnlineYudGimelDaledSignIn\OnlineYudGimelDaledSignIn\Site.Master.cs:29
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
System.Web.UI.Control.OnLoad(EventArgs e) +97
System.Web.UI.Control.LoadRecursive() +61
System.Web.UI.Control.LoadRecursive() +134
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693
Im stumped as to why, the same function with the same arguments works from an other project.
I tried sending different arguments to the function and i get different error, but i need it to be these arguments.
Ok, so i had a missing connection string in the web.config file in the second project. I didn't realize dll reference uses the current project config file, and not his own somehow.

Working ActiveDirectoryMembershipProvider in Classic Cloud Services but do not work on Azure Web App

We have a working ASP.Net Web Application (.NET Framework not Core) on .NET 4.7.2 that was deployed to a classic cloud services. We are trying to deploy it to the Azure App Services. Majority of the existing functionality are working good so far. Unfortunately we are having trouble with getting the ActiveDirectoryMembershipProvider as part of the FormsAuthentication working.
Our LDAP is hosted in AWS an will be accessed by IP Address. For debugging purposes we try it on unsecured LDAP (port 389). We can reach the LDAP from the machine, we can get the group memberships of the test ldap user. However, using the built in ActiveDirectoryMembershipProvider we're getting the error below
Exception type System.Configuration.ConfigurationErrorsException
Exception message Access is denied.
(D:\home\site\wwwroot\web.config line 242) <--- Access is denied.
System.Configuration.ConfigurationErrorsException: Access is denied.
(D:\home\site\wwwroot\web.config line 242) ---> System.UnauthorizedAccessException: Access is denied.
at System.DirectoryServices.ActiveDirectory.DirectoryContext.IsContextValid(DirectoryContext context, DirectoryContextType contextType)
at System.DirectoryServices.ActiveDirectory.DirectoryContext.isDomain()
at System.DirectoryServices.ActiveDirectory.Domain.GetDomain(DirectoryContext context)
at System.Web.Security.DirectoryInformation.InitializeDomainAndForestName()
at System.Web.Security.ActiveDirectoryMembershipProvider.Initialize(String name, NameValueCollection config)
at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
--- End of inner exception stack trace ---
at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
at System.Web.Configuration.ProvidersHelper.InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
at System.Web.Security.Membership.InitializeSettings(Boolean initializeGeneralSettings, RuntimeConfig appConfig, MembershipSection settings)
at System.Web.Security.Membership.Initialize()
at System.Web.Security.Membership.get_Provider()
at System.Web.Security.Membership.ValidateUser(String username, String password)
at <ASPX METHOD>:.ValidateUser(String username, String password) in <ASPX CODEBEHIND>:line 56
at <ASPX METHOD>(Object sender, EventArgs e) in <ASPX CODEBEHIND>::line 26
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.<ASPX CODEBEHIND>:.ProcessRequest(HttpContext context) in d:\local\Temporary ASP.NET Files\root\0a1c09b7\daf71945\App_Web_ahzd2zi1.4.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()
at System.Web.HttpApplication.StepInvoker.Invoke(Action executionStep)
at System.Web.HttpApplication.StepInvoker.<>c__DisplayClass4_0.<Invoke>b__0()
at Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule.OnExecuteRequestStep(HttpContextBase context, Action step)
at System.Web.HttpApplication.<>c__DisplayClass284_0.<OnExecuteRequestStep>b__0(Action nextStepAction)
at System.Web.HttpApplication.StepInvoker.Invoke(Action executionStep)
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The membership config are as follows
<membership defaultProvider="MyADMembershipProvider">
<providers>
<clear />
<add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" connectionUsername="<DOMAIN>\<USERNAME>" connectionPassword="<PASSWORD>" />
</providers>
</membership>
The connection string is
<add name="ADConnectionString" connectionString="LDAP://<IPADDRESS>:<PORT>/DC=<DOMAIN>,DC=local" />
Can't seem to find anything that would indicate that there is something different running it in Azure. Any insight is appreciated.
Azure App Services do not work with Active directory. You may want to explore Azure Active Directory.
LDAP will not work on Cloud directly. You will have to use Azure AD Domain Services - https://learn.microsoft.com/en-us/azure/active-directory-domain-services/configure-ldaps
Also, App services is a sandboxed environment.

Why is Application Insights Preventing my Worker Role from Starting?

I have an Azure Cloud Service with a single worker role that will deploy, start, and run without fail every time, but I ran into some intermittent problems I wanted to diagnose with Application Insights. I followed directions from this article as well as here.
After installing the nugget packages and adding the one line of code, I ran the cloud service locally in both debug and release mode, and was able to see the AI info being reported to the Application Insights resource. So I packaged it up and uploaded the new configuration to my cloud service.
But then from the cloud the worker role will not actually start--it goes into a recycle death spiral, and in the "Diagnose and Solve Problems" blade I get a variation of the error below, always about "System.Threading.AsyncLocal'1'" and not being able to load the RoleEntryPoint. Following this article did not shed much light onto things, as the error pretty much tells me why it keeps recycling but not any clues on what to do about it.
Production - WebReportDownloader_IN_0: BusyRole
Waiting for role to start... Failed to load role entrypoint. System.TypeLoadException: Could not load type 'System.Threading.AsyncLocal`1' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. at Microsoft.ApplicationInsights.Extensibility.SdkInternalOperationsMonitor.Exit() at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.Initialize(TelemetryConfiguration configuration, TelemetryModules modules, String serializedConfiguration) at Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.get_Active() at WebReportDownloader..ctor() in C:\Users\User\Source\Repos\Program\WebReportDownloader\WebReportDownloader.cs:line 21 --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum) [2017-09-14T15:28:21Z] Last exit time: [2017/09/14, 15:28:21.944]. Last exit code: 0.
Normally I can get enough of a hint from searching the exception and/or details, but this time I can't find anything that resembles my problem. All I can guess is that something small but critical is awry with my configuration, but I haven't been able to determine where I've gone off the rails based on the instructions I linked above.
My ServiceConfiguration.Cloud file...
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="WebReportDownloader" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
<Role name="WebReportDownloader">
<Instances count="2" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="admin" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="ENCRYPTEDVALUE" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2018-09-01T23:59:59.0000000-04:00" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value="KEYVALUE" />
</ConfigurationSettings>
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="847EEDE0084CF57A5A774CAE9E700713726CC856" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
And my ApplicationInsights.config...
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
<TelemetryInitializers>
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
</TelemetryInitializers>
<TelemetryModules>
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
<ExcludeComponentCorrelationHttpHeadersOnDomains>
<!--
Requests to the following hostnames will not be modified by adding correlation headers.
This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
Add entries here to exclude additional hostnames.
NOTE: this configuration will be lost upon NuGet upgrade.
-->
<Add>core.windows.net</Add>
<Add>core.chinacloudapi.cn</Add>
<Add>core.cloudapi.de</Add>
<Add>core.usgovcloudapi.net</Add>
<Add>localhost</Add>
<Add>127.0.0.1</Add>
</ExcludeComponentCorrelationHttpHeadersOnDomains>
</Add>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
<!--
Use the following syntax here to collect additional performance counters:
<Counters>
<Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
...
</Counters>
PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
NOTE: performance counters configuration will be lost upon NuGet upgrade.
The following placeholders are supported as InstanceName:
??APP_WIN32_PROC?? - instance name of the application process for Win32 counters.
??APP_W3SVC_PROC?? - instance name of the application IIS worker process for IIS/ASP.NET counters.
??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
-->
</Add>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer">
<!--</Add>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer">-->
</Add>
</TelemetryModules>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
<ExcludedTypes>Event</ExcludedTypes>
</Add>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
<IncludedTypes>Event</IncludedTypes>
</Add>
</TelemetryProcessors>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
<!--
Learn more about Application Insights configuration with ApplicationInsights.config here:
http://go.microsoft.com/fwlink/?LinkID=513840
Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
--></ApplicationInsights>
And my "OnStart()" method where I actually set the InstrumentationKey...
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
TelemetryConfiguration.Active.InstrumentationKey = RoleEnvironment.GetConfigurationSettingValue("APPINSIGHTS_INSTRUMENTATIONKEY");
// For information on handling configuration changes
// see the MSDN topic at https://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
Trace.TraceInformation("WebReportDownloader has been started");
return result;
}
I would appreciate any insight (ha!) or guidance anyone can provide...
Update:
Through further experimentation, I've determined that whenever I'm trying to call the Application Insights assembly directly (such as when creating a Telemetry Client or setting the ApplicationInsights Resource Key directly) or when the ApplicationInsight TraceListener is called because of a trace the exception below is called
Could not load type 'System.Threading.AsyncLocal`1' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
If I do the run-time instrumentation, I'm able to get some basic traces and logs to my Insight resources, but attempting to get anything more still escapes me.
Additionally, I'm currently targeting .NET 4.6.1 (information I neglected to mention previously).
After much back and forth with Azure support, I was finally able to get a screen sharing session set up. The helpful gentleman zeroed in on the problem almost immediately: Because my worker role project targets .NET 4.6.1 the ServiceConfiguration files (both .Cloud.cscfg and .Local.cscfg) need to be targeting osFamily 5.
The defaults generated by the VS17 wizard set it at osFamily=4 as seen below...
However, what I needed to make everything run properly was to be targeting osFamily=5 as seen below...
That one small change allowed the web role to deploy properly while instantiating a TelemetryClient.
According to your description, I created my Azure Cloud Service project and added the single Worker Role targets on .NET Framework 4.5, then installed Microsoft.ApplicationInsights.WindowsServer 2.4.1 and just added the code as you mentioned for setting the instrumentation key as follows:
WorkerRole.cs
public class WorkerRole : RoleEntryPoint
{
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
private readonly ManualResetEvent runCompleteEvent = new ManualResetEvent(false);
public override void Run()
{
Trace.TraceInformation("WorkerRoleB is running");
try
{
this.RunAsync(this.cancellationTokenSource.Token).Wait();
}
finally
{
this.runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
TelemetryConfiguration.Active.InstrumentationKey = RoleEnvironment.GetConfigurationSettingValue("APPINSIGHTS_INSTRUMENTATIONKEY");
// For information on handling configuration changes
// see the MSDN topic at https://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
Trace.TraceInformation("WorkerRoleB has been started");
return result;
}
public override void OnStop()
{
Trace.TraceInformation("WorkerRoleB is stopping");
this.cancellationTokenSource.Cancel();
this.runCompleteEvent.WaitOne();
base.OnStop();
Trace.TraceInformation("WorkerRoleB has stopped");
}
private async Task RunAsync(CancellationToken cancellationToken)
{
// TODO: Replace the following with your own logic.
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
await Task.Delay(1000);
}
}
}
After deployed to Azure Cloud Service, it could work as expected and I could retrieve the diagnostic data from AI as follows:
Note: As Install the SDK in each project states that you need to set the ApplicationInsights.config file to be copied always to the output directory.
Additionally, you could refer to the quick start and instruments your app at run time to narrow this issue. Moreover, if I missed something or you did some other special code, you could update your question for us to troubleshoot this issue.

Debugging compiled function in ASP .NET

I have a website I believe to be in ASP .NET, which is throwing an exception System.NullReferenceException: Object reference not set to an instance of an object.. Stack trace shows as follows:
[NullReferenceException: Object reference not set to an instance of an object.]
SomeScript.getConnection() +32
SomeScript.buildGridData() +299
SomeScript.Page_Load(Object sender, EventArgs e) +92
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +43
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Control.LoadRecursive() +163
System.Web.UI.Control.LoadRecursive() +163
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2603
Same error is occurring for basically all pages of the site which request data, with just the SomeScript in above stack trace alternating for the loading script.
Environmental changes have only been in changing password for a remote SMTP server the site uses for mailing out, but site was continuing to load fine after that change was made.
My feeling is that these errors with the getConnection() method started occurring after a user tried to use said SMTP mailing function within the website and received an error (I was not able to capture the error user received).
I'm a bit lost with debugging any further from here as the getConnection() method seems to be within compiled DLLs and not accessible by me.
What is the next step in trying to remove the error?
Firstly, it's unlikely that an SMTP password change has caused the issue from your description of it. But if that password change was made in the Web.config file, I'd say it's possible it was made less carefully than it should have been, and in fact a database connection-related section in there has been inadvertently modified and is no longer valid.
If you want to be able to debug into the DLL, you can disable the option to debug "Just My Code" in Visual Studio (something like Tools/Options/Debugging) - you should then be able to step down into these DLLs and see where the issue lies. Hopefully it won't require any code changes, and you can just fix up the configuration file.

WebException: The server committed a protocol violation. Section=ResponseStatusLine (call Marketo SOAP API)

I'm trying to call the Marketo SOAP Webservice
via ASP.NET / C#.
I successfully added the web service reference and tried to call it with this line of code:
SuccessGetLead lead = service.getLead(paramsgetlead);
The problem is I also get this exception:
[WebException: The server committed a protocol violation. Section=ResponseStatusLine]
System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) +263
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) +4
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +172
com.marketo.soap.MktMktowsApiService.getLead(ParamsGetLead paramsGetLead) in c:\Users\hubert.grininger\AppData\Local\Temp\Temporary ASP.NET Files\dynaweb2007\82e21235\d41bf12a\App_WebReferences.liqikruc.7.cs:206
_test_marketo.Page_Load(Object sender, EventArgs e) in d:\workspace_c\dynaweb2007_test\marketo.aspx.cs:48
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
I also tried adding
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing = "true" />
</settings>
</system.net>
but that didn't help either.
I think the request is never sent to Marketo but the error already occurs on my end.
Thanks for any help or hint.
Solved. Problem was that the wsdl (provided by Marketo) wrongly pointed to localhost as webservice endpoint.
I programmatically set the URL via WebServiceObject.Url property and it works now.
Just try to use HTTP/1.0 instead of HTTP/1.1
look at the following code
objWebRequest.ProtocolVersion = System.Net.HttpVersion.Version10;
It worked for me ;-)

Categories

Resources